diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 582d6a9e0..5590d1939 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -46,7 +46,7 @@ module Abilities can [:read, :create, :update, :destroy], Budget::Group can [:read, :create, :update, :destroy], Budget::Heading can [:hide, :update, :toggle_selection], Budget::Investment - can :valuate, Budget::Investment, budget: { phase: 'valuating' } + can :valuate, Budget::Investment can :create, Budget::ValuatorAssignment can [:search, :edit, :update, :create, :index, :destroy], Banner diff --git a/app/models/abilities/valuator.rb b/app/models/abilities/valuator.rb index 1462e2630..614869665 100644 --- a/app/models/abilities/valuator.rb +++ b/app/models/abilities/valuator.rb @@ -5,7 +5,8 @@ module Abilities def initialize(user) valuator = user.valuator can [:read, :update, :valuate], SpendingProposal - can [:read, :update, :valuate], Budget::Investment, id: valuator.investment_ids, budget: { phase: 'valuating' } + can [:read, :update, :valuate], Budget::Investment, id: valuator.investment_ids + cannot [:update, :valuate], Budget::Investment, budget: { phase: 'finished' } end end end diff --git a/spec/models/abilities/administrator_spec.rb b/spec/models/abilities/administrator_spec.rb index 8f48153a8..8c4e8a1ef 100644 --- a/spec/models/abilities/administrator_spec.rb +++ b/spec/models/abilities/administrator_spec.rb @@ -66,6 +66,6 @@ describe "Abilities::Administrator" do it { should be_able_to(:hide, Budget::Investment) } it { should be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: 'valuating'))) } - it { should_not be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: 'finished'))) } + it { should be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: 'finished'))) } end diff --git a/spec/models/abilities/valuator_spec.rb b/spec/models/abilities/valuator_spec.rb index fee24f6a8..c3735b43b 100644 --- a/spec/models/abilities/valuator_spec.rb +++ b/spec/models/abilities/valuator_spec.rb @@ -10,8 +10,8 @@ describe "Abilities::Valuator" do let(:assigned_investment) { create(:budget_investment, budget: create(:budget, phase: 'valuating')) } before(:each) { assigned_investment.valuators << valuator } - let(:assigned_investment_not_valuating) { create(:budget_investment, budget: create(:budget, phase: 'finished')) } - before(:each) { assigned_investment_not_valuating.valuators << valuator } + let(:finished_assigned_investment) { create(:budget_investment, budget: create(:budget, phase: 'finished')) } + before(:each) { finished_assigned_investment.valuators << valuator } it { should be_able_to(:read, SpendingProposal) } it { should be_able_to(:update, SpendingProposal) } @@ -23,6 +23,6 @@ describe "Abilities::Valuator" do it { should be_able_to(:update, assigned_investment) } it { should be_able_to(:valuate, assigned_investment) } - it { should_not be_able_to(:update, assigned_investment_not_valuating) } - it { should_not be_able_to(:valuate, assigned_investment_not_valuating) } + it { should_not be_able_to(:update, finished_assigned_investment) } + it { should_not be_able_to(:valuate, finished_assigned_investment) } end