Merge pull request #2390 from wairbut-m2c/aperez-user-permissions-specs
Add specs to check users permissions to delete images & documents
This commit is contained in:
@@ -12,16 +12,16 @@ describe Abilities::Administrator do
|
||||
|
||||
let(:debate) { create(:debate) }
|
||||
let(:comment) { create(:comment) }
|
||||
let(:proposal) { create(:proposal) }
|
||||
let(:proposal) { create(:proposal, author: user) }
|
||||
let(:budget_investment) { create(:budget_investment) }
|
||||
let(:legislation_question) { create(:legislation_question) }
|
||||
let(:poll_question) { create(:poll_question) }
|
||||
|
||||
let(:proposal_document) { build(:document, documentable: proposal) }
|
||||
let(:proposal_document) { build(:document, documentable: proposal, user: proposal.author) }
|
||||
let(:budget_investment_document) { build(:document, documentable: budget_investment) }
|
||||
let(:poll_question_document) { build(:document, documentable: poll_question) }
|
||||
|
||||
let(:proposal_image) { build(:image, imageable: proposal) }
|
||||
let(:proposal_image) { build(:image, imageable: proposal, user: proposal.author) }
|
||||
let(:budget_investment_image) { build(:image, imageable: budget_investment) }
|
||||
|
||||
let(:hidden_debate) { create(:debate, :hidden) }
|
||||
@@ -82,4 +82,9 @@ describe Abilities::Administrator do
|
||||
|
||||
it { should be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: 'valuating'))) }
|
||||
it { should be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: 'finished'))) }
|
||||
|
||||
it { should be_able_to(:destroy, proposal_image) }
|
||||
it { should be_able_to(:destroy, proposal_document) }
|
||||
it { should_not be_able_to(:destroy, budget_investment_image) }
|
||||
it { should_not be_able_to(:destroy, budget_investment_document) }
|
||||
end
|
||||
|
||||
@@ -152,6 +152,12 @@ describe Abilities::Common do
|
||||
it { should be_able_to(:edit, own_proposal) }
|
||||
it { should_not be_able_to(:edit, proposal) } # Not his
|
||||
it { should_not be_able_to(:edit, own_proposal_non_editable) }
|
||||
|
||||
it { should be_able_to(:destroy, own_proposal_image) }
|
||||
it { should be_able_to(:destroy, own_proposal_document) }
|
||||
|
||||
it { should_not be_able_to(:destroy, proposal_image) }
|
||||
it { should_not be_able_to(:destroy, proposal_document) }
|
||||
end
|
||||
|
||||
describe "when level 2 verified" do
|
||||
@@ -218,8 +224,8 @@ describe Abilities::Common do
|
||||
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_accepting_budget) }
|
||||
it { should_not be_able_to(:vote, investment_in_balloting_budget) }
|
||||
|
||||
it { should_not be_able_to(:destroy, investment_in_accepting_budget) }
|
||||
@@ -232,9 +238,15 @@ describe Abilities::Common do
|
||||
it { should_not be_able_to(:destroy, own_investment_in_selecting_budget) }
|
||||
it { should_not be_able_to(:destroy, own_investment_in_balloting_budget) }
|
||||
|
||||
it { should be_able_to(:create, ballot_in_balloting_budget) }
|
||||
it { should_not be_able_to(:create, ballot_in_accepting_budget) }
|
||||
it { should_not be_able_to(:create, ballot_in_selecting_budget) }
|
||||
it { should be_able_to(:create, ballot_in_balloting_budget) }
|
||||
|
||||
it { should be_able_to(:destroy, own_budget_investment_image) }
|
||||
it { should be_able_to(:destroy, own_budget_investment_document) }
|
||||
|
||||
it { should_not be_able_to(:destroy, budget_investment_image) }
|
||||
it { should_not be_able_to(:destroy, budget_investment_document) }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user