Don't generate stats for budget polls

The link to show stats for these polls is nowhere to be seen in the
application, and these stats are included in the budget stats, so it
makes sense to restrict access to them.
This commit is contained in:
Javi Martín
2019-11-09 15:02:32 +01:00
parent 01a01c834d
commit ed6a4a1b95
2 changed files with 4 additions and 2 deletions

View File

@@ -7,8 +7,8 @@ module Abilities
can [:read, :map, :summary, :share], Proposal
can :read, Comment
can :read, Poll
can :results, Poll, id: Poll.expired.results_enabled.ids
can :stats, Poll, id: Poll.expired.stats_enabled.ids
can :results, Poll, id: Poll.expired.results_enabled.not_budget.ids
can :stats, Poll, id: Poll.expired.stats_enabled.not_budget.ids
can :read, Poll::Question
can :read, User
can [:read, :welcome], Budget

View File

@@ -34,10 +34,12 @@ describe Abilities::Everyone do
it { should be_able_to(:results, create(:poll, :expired, results_enabled: true)) }
it { should_not be_able_to(:results, create(:poll, :expired, results_enabled: false)) }
it { should_not be_able_to(:results, create(:poll, :current, results_enabled: true)) }
it { should_not be_able_to(:results, create(:poll, :for_budget, :expired, results_enabled: true)) }
it { should be_able_to(:stats, create(:poll, :expired, stats_enabled: true)) }
it { should_not be_able_to(:stats, create(:poll, :expired, stats_enabled: false)) }
it { should_not be_able_to(:stats, create(:poll, :current, stats_enabled: true)) }
it { should_not be_able_to(:stats, create(:poll, :for_budget, :expired, stats_enabled: true)) }
it { should be_able_to(:read_results, create(:budget, :finished, results_enabled: true)) }
it { should_not be_able_to(:read_results, create(:budget, :finished, results_enabled: false)) }