Move budget stats permission tests to the model
They're easier to test and to read in the model.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user