Move budget stats permission tests to the model

They're easier to test and to read in the model.
This commit is contained in:
Javi Martín
2019-04-29 18:58:25 +02:00
parent eb13994999
commit c00203f7f5
2 changed files with 14 additions and 16 deletions

View File

@@ -7,22 +7,6 @@ feature "Stats" do
let(:heading) { create(:budget_heading, group: group, price: 1000) }
describe "Show" do
it "is not accessible if supports phase is not finished" do
budget.update(phase: "selecting")
visit budget_stats_path(budget.id)
expect(page).to have_content "You do not have permission to carry out the action "\
"'read_stats' on budget."
end
it "is accessible if supports phase is finished" do
budget.update(phase: "valuating")
visit budget_stats_path(budget.id)
expect(page).to have_content "Stats"
end
end
end

View File

@@ -73,4 +73,18 @@ describe Abilities::Everyone do
it { should_not be_able_to(:stats, poll) }
end
end
context "when accessing budget stats" do
context "supports phase is not finished" do
let(:budget) { create(:budget, phase: "selecting") }
it { should_not be_able_to(:read_stats, budget) }
end
context "supports phase is finished" do
let(:budget) { create(:budget, phase: "valuating") }
it { should be_able_to(:read_stats, budget) }
end
end
end