Admins can see the preview of the budgets' results before the balloting phase is finished.

Cambios para hacer commit:
	modificado:    app/models/abilities/administrator.rb
	modificado:    app/views/budgets/show.html.erb
	modificado:    spec/models/abilities/administrator_spec.rb
	modificado:    spec/models/abilities/everyone_spec.rb
This commit is contained in:
iagirre
2017-09-26 11:16:32 +02:00
parent 3c2b5281e8
commit e90ac7e72d
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

@@ -69,6 +69,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