Merge pull request #1923 from wairbut-m2c/iagirre-preview-budget-results

Admins can see the preview of the budgets' results before the balloti…
This commit is contained in:
BertoCQ
2017-10-02 21:40:04 +02:00
committed by GitHub
4 changed files with 10 additions and 3 deletions

View File

@@ -45,7 +45,7 @@ module Abilities
can [:read, :update, :valuate, :destroy, :summary], SpendingProposal
can [:index, :read, :new, :create, :update, :destroy, :calculate_winners], Budget
can [:index, :read, :new, :create, :update, :destroy, :calculate_winners, :read_results], Budget
can [:read, :create, :update, :destroy], Budget::Group
can [:read, :create, :update, :destroy], Budget::Heading
can [:hide, :update, :toggle_selection], Budget::Investment

View File

@@ -36,7 +36,7 @@
<% end %>
<% end %>
<% if @budget.finished? %>
<% if @budget.finished? || (@budget.balloting? && can?(:read_results, @budget)) %>
<%= link_to t("budgets.show.see_results"),
budget_results_path(@budget, heading_id: @budget.headings.first),
class: "button margin-top expanded" %>

View File

@@ -72,6 +72,7 @@ describe "Abilities::Administrator" do
it { should be_able_to(:create, Budget) }
it { should be_able_to(:update, Budget) }
it { should be_able_to(:read_results, Budget) }
it { should be_able_to(:create, Budget::ValuatorAssignment) }

View File

@@ -8,6 +8,9 @@ describe "Abilities::Everyone" do
let(:debate) { create(:debate) }
let(:proposal) { create(:proposal) }
let(:reviewing_ballot_budget) { create(:budget, phase: 'reviewing_ballots') }
let(:finished_budget) { create(:budget, phase: 'finished') }
it { should be_able_to(:index, Debate) }
it { should be_able_to(:show, debate) }
it { should_not be_able_to(:edit, Debate) }
@@ -28,4 +31,7 @@ describe "Abilities::Everyone" do
it { should_not be_able_to(:create, SpendingProposal) }
it { should be_able_to(:index, Budget) }
end
it { should be_able_to(:read_results, finished_budget) }
it { should_not be_able_to(:read_results, reviewing_ballot_budget) }
end