Remove unneeded lines restricting permissions
In the past, users had permission to edit their own legislation
proposals. However, that changed in commit ebfa3fb01, where we replaced
the `can` method with `cannot`.
An easier way to remove this permission is to simply remove the whole
statement, since by default users don't have permissions to do anything.
We're also adding a test checking users can't edit their own legislation
proposals, since it was missing.
This commit is contained in:
@@ -39,9 +39,6 @@ module Abilities
|
|||||||
can [:retire_form, :retire], Proposal, author_id: user.id
|
can [:retire_form, :retire], Proposal, author_id: user.id
|
||||||
|
|
||||||
can :read, Legislation::Proposal
|
can :read, Legislation::Proposal
|
||||||
cannot [:edit, :update], Legislation::Proposal do |proposal|
|
|
||||||
proposal.editable_by?(user)
|
|
||||||
end
|
|
||||||
can [:retire_form, :retire], Legislation::Proposal, author_id: user.id
|
can [:retire_form, :retire], Legislation::Proposal, author_id: user.id
|
||||||
|
|
||||||
can :create, Comment
|
can :create, Comment
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ describe Abilities::Common do
|
|||||||
let(:own_debate) { create(:debate, author: user) }
|
let(:own_debate) { create(:debate, author: user) }
|
||||||
let(:own_comment) { create(:comment, author: user) }
|
let(:own_comment) { create(:comment, author: user) }
|
||||||
let(:own_proposal) { create(:proposal, author: user) }
|
let(:own_proposal) { create(:proposal, author: user) }
|
||||||
|
let(:own_legislation_proposal) { create(:legislation_proposal, author: user) }
|
||||||
|
|
||||||
let(:accepting_budget) { create(:budget, :accepting) }
|
let(:accepting_budget) { create(:budget, :accepting) }
|
||||||
let(:reviewing_budget) { create(:budget, :reviewing) }
|
let(:reviewing_budget) { create(:budget, :reviewing) }
|
||||||
@@ -167,6 +168,9 @@ describe Abilities::Common do
|
|||||||
it { should_not be_able_to(:destroy, proposal_document) }
|
it { should_not be_able_to(:destroy, proposal_document) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it { should_not be_able_to(:edit, own_legislation_proposal) }
|
||||||
|
it { should_not be_able_to(:update, own_legislation_proposal) }
|
||||||
|
|
||||||
describe "proposals dashboard" do
|
describe "proposals dashboard" do
|
||||||
it { should be_able_to(:dashboard, own_proposal) }
|
it { should be_able_to(:dashboard, own_proposal) }
|
||||||
it { should_not be_able_to(:dashboard, proposal) }
|
it { should_not be_able_to(:dashboard, proposal) }
|
||||||
|
|||||||
Reference in New Issue
Block a user