diff --git a/app/models/abilities/common.rb b/app/models/abilities/common.rb index 6dd36d5b0..ed2c3d4a0 100644 --- a/app/models/abilities/common.rb +++ b/app/models/abilities/common.rb @@ -19,6 +19,7 @@ module Abilities can [:retire_form, :retire], Proposal, author_id: user.id can :read, SpendingProposal + can :read, Budget::Investment can :create, Comment can :create, Debate @@ -46,6 +47,9 @@ module Abilities can :vote_featured, Proposal can :vote, SpendingProposal can :create, SpendingProposal + can :create, Budget::Investment, budget: { phase: "accepting" } + can :vote, Budget::Investment, budget: { phase: "selecting" } + can :ballot, Budget::Investment, budget: { phase: "balloting" } end can :create, Annotation diff --git a/spec/models/abilities/common_spec.rb b/spec/models/abilities/common_spec.rb index 468173797..36b4b49f6 100644 --- a/spec/models/abilities/common_spec.rb +++ b/spec/models/abilities/common_spec.rb @@ -9,6 +9,9 @@ describe "Abilities::Common" do let(:debate) { create(:debate) } let(:comment) { create(:comment) } let(:proposal) { create(:proposal) } + let(:investment_in_accepting_budget) { create(:budget_investment, budget: create(:budget, phase: 'accepting')) } + let(:investment_in_selecting_budget) { create(:budget_investment, budget: create(:budget, phase: 'selecting')) } + let(:investment_in_balloting_budget) { create(:budget_investment, budget: create(:budget, phase: 'balloting')) } let(:own_debate) { create(:debate, author: user) } let(:own_comment) { create(:comment, author: user) } let(:own_proposal) { create(:proposal, author: user) } @@ -93,6 +96,19 @@ describe "Abilities::Common" do it { should be_able_to(:create, SpendingProposal) } it { should_not be_able_to(:destroy, create(:spending_proposal)) } it { should_not be_able_to(:destroy, own_spending_proposal) } + + it { should be_able_to(:create, investment_in_accepting_budget) } + it { should_not be_able_to(:create, investment_in_selecting_budget) } + it { should_not be_able_to(:create, investment_in_balloting_budget) } + + it { should_not be_able_to(:vote, investment_in_accepting_budget) } + it { should be_able_to(:vote, investment_in_selecting_budget) } + it { should_not be_able_to(:vote, investment_in_balloting_budget) } + + it { should_not be_able_to(:ballot, investment_in_accepting_budget) } + it { should_not be_able_to(:ballot, investment_in_selecting_budget) } + it { should be_able_to(:ballot, investment_in_balloting_budget) } + end describe "when level 3 verified" do