diff --git a/app/models/abilities/common.rb b/app/models/abilities/common.rb index 002518dac..92eacea52 100644 --- a/app/models/abilities/common.rb +++ b/app/models/abilities/common.rb @@ -25,7 +25,7 @@ module Abilities can :suggest, Debate can :suggest, Proposal - + can [:flag, :unflag], Comment cannot [:flag, :unflag], Comment, user_id: user.id @@ -44,6 +44,7 @@ module Abilities can :vote, Proposal can :vote_featured, Proposal can :create, SpendingProposal + can :destroy, SpendingProposal, author_id: user.id end can :create, Annotation diff --git a/spec/models/abilities/common_spec.rb b/spec/models/abilities/common_spec.rb index d942e2d18..8c90f7cea 100644 --- a/spec/models/abilities/common_spec.rb +++ b/spec/models/abilities/common_spec.rb @@ -30,6 +30,7 @@ describe "Abilities::Common" do it { should be_able_to(:index, SpendingProposal) } it { should_not be_able_to(:create, SpendingProposal) } + it { should_not be_able_to(:destroy, SpendingProposal) } it { should_not be_able_to(:comment_as_administrator, debate) } it { should_not be_able_to(:comment_as_moderator, debate) } @@ -83,20 +84,26 @@ describe "Abilities::Common" do end describe "when level 2 verified" do + let(:own_spending_proposal) { create(:spending_proposal, author: user) } before{ user.update(residence_verified_at: Time.now, confirmed_phone: "1") } it { should be_able_to(:vote, Proposal) } it { should be_able_to(:vote_featured, Proposal) } it { should be_able_to(:create, SpendingProposal) } + it { should_not be_able_to(:destroy, create(:spending_proposal)) } + it { should be_able_to(:destroy, own_spending_proposal) } end describe "when level 3 verified" do + let(:own_spending_proposal) { create(:spending_proposal, author: user) } before{ user.update(verified_at: Time.now) } it { should be_able_to(:vote, Proposal) } it { should be_able_to(:vote_featured, Proposal) } it { should be_able_to(:create, SpendingProposal) } + it { should_not be_able_to(:destroy, create(:spending_proposal)) } + it { should be_able_to(:destroy, own_spending_proposal) } end end