adds ability to level 2 users to delete owned sps

This commit is contained in:
Juanjo Bazán
2016-03-14 12:51:58 +01:00
parent 0b1b4384ee
commit 142c981cdf
2 changed files with 9 additions and 1 deletions

View File

@@ -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

View File

@@ -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