From 7005faabe6c4ba1030935eafadce39bad87b94e5 Mon Sep 17 00:00:00 2001 From: kikito Date: Mon, 30 May 2016 14:13:36 +0200 Subject: [PATCH] adds admin permissions for investments --- app/models/abilities/administrator.rb | 8 ++++++-- spec/models/abilities/administrator_spec.rb | 12 ++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 6b77c130d..b86723c93 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -4,7 +4,6 @@ module Abilities def initialize(user) self.merge Abilities::Moderation.new(user) - self.merge Abilities::Valuator.new(user) can :restore, Comment cannot :restore, Comment, hidden_at: nil @@ -41,7 +40,12 @@ module Abilities can :manage, Annotation - can [:read, :update, :destroy, :summary], SpendingProposal + can [:read, :update, :valuate, :destroy, :summary], SpendingProposal + + can [:create, :update], Budget + can [:hide, :update], Budget::Investment + can :valuate, Budget::Investment, budget: { valuating: true } + can :create, Budget::ValuatorAssignment end end end diff --git a/spec/models/abilities/administrator_spec.rb b/spec/models/abilities/administrator_spec.rb index f9ed7a0c5..8170d3434 100644 --- a/spec/models/abilities/administrator_spec.rb +++ b/spec/models/abilities/administrator_spec.rb @@ -56,4 +56,16 @@ describe "Abilities::Administrator" do it { should be_able_to(:update, SpendingProposal) } it { should be_able_to(:valuate, SpendingProposal) } it { should be_able_to(:destroy, SpendingProposal) } + + it { should be_able_to(:create, Budget) } + it { should be_able_to(:update, Budget) } + + it { should be_able_to(:create, Budget::ValuatorAssignment) } + + it { should be_able_to(:update, Budget::Investment) } + it { should be_able_to(:hide, Budget::Investment) } + + it { should be_able_to(:valuate, create(:budget_investment, budget: create(:budget, valuating: true))) } + it { should_not be_able_to(:valuate, create(:budget_investment, budget: create(:budget, valuating: false))) } + end