diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index f08a1a2cc..ba2f4070d 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -48,7 +48,7 @@ module Abilities can [:index, :read, :new, :create, :update, :destroy, :calculate_winners], Budget can [:read, :create, :update, :destroy], Budget::Group can [:read, :create, :update, :destroy], Budget::Heading - can [:hide, :update, :toggle_selection, :edit_image, :update_image, :remove_image], Budget::Investment + can [:hide, :update, :toggle_selection], Budget::Investment can :valuate, Budget::Investment can :create, Budget::ValuatorAssignment diff --git a/app/models/abilities/common.rb b/app/models/abilities/common.rb index 169772dc2..8c339ec5a 100644 --- a/app/models/abilities/common.rb +++ b/app/models/abilities/common.rb @@ -58,9 +58,6 @@ module Abilities can :suggest, Budget::Investment, budget: { phase: "accepting" } can :destroy, Budget::Investment, budget: { phase: ["accepting", "reviewing"] }, author_id: user.id can :vote, Budget::Investment, budget: { phase: "selecting" } - can :edit_image, Budget::Investment, author_id: user.id - can :update_image, Budget::Investment, author_id: user.id - can :remove_image, Budget::Investment, author_id: user.id can [:show, :create], Budget::Ballot, budget: { phase: "balloting" } can [:create, :destroy], Budget::Ballot::Line, budget: { phase: "balloting" } diff --git a/spec/models/abilities/administrator_spec.rb b/spec/models/abilities/administrator_spec.rb index be9eb060d..f6a970b94 100644 --- a/spec/models/abilities/administrator_spec.rb +++ b/spec/models/abilities/administrator_spec.rb @@ -85,10 +85,6 @@ describe "Abilities::Administrator" do it { should be_able_to(:create, proposal_document) } it { should be_able_to(:destroy, proposal_document) } - it { should be_able_to(:new, proposal_image) } - it { should be_able_to(:create, proposal_image) } - it { should be_able_to(:destroy, proposal_image) } - it { should be_able_to(:new, budget_investment_document) } it { should be_able_to(:create, budget_investment_document) } it { should be_able_to(:destroy, budget_investment_document) } @@ -97,6 +93,10 @@ describe "Abilities::Administrator" do it { should be_able_to(:create, poll_question_document) } it { should be_able_to(:destroy, poll_question_document) } + it { should be_able_to(:new, proposal_image) } + it { should be_able_to(:create, proposal_image) } + it { should be_able_to(:destroy, proposal_image) } + it { should be_able_to(:new, budget_investment_image) } it { should be_able_to(:create, budget_investment_image) } it { should be_able_to(:destroy, budget_investment_image) } diff --git a/spec/models/abilities/common_spec.rb b/spec/models/abilities/common_spec.rb index 51145a568..75a99fd53 100644 --- a/spec/models/abilities/common_spec.rb +++ b/spec/models/abilities/common_spec.rb @@ -59,6 +59,11 @@ describe "Abilities::Common" do let(:own_budget_investment_document) { build(:document, documentable: own_investment_in_accepting_budget) } let(:budget_investment_document) { build(:document, documentable: investment_in_accepting_budget) } + let(:own_proposal_image) { build(:image, imageable: own_proposal) } + let(:proposal_image) { build(:image, imageable: proposal) } + let(:own_budget_investment_image) { build(:image, imageable: own_investment_in_accepting_budget) } + let(:budget_investment_image) { build(:image, imageable: investment_in_accepting_budget) } + it { should be_able_to(:index, Debate) } it { should be_able_to(:show, debate) } it { should be_able_to(:vote, debate) } @@ -106,6 +111,22 @@ describe "Abilities::Common" do it { should_not be_able_to(:create, budget_investment_document) } it { should_not be_able_to(:destroy, budget_investment_document) } + it { should be_able_to(:new, own_proposal_image) } + it { should be_able_to(:create, own_proposal_image) } + it { should be_able_to(:destroy, own_proposal_image) } + + it { should_not be_able_to(:new, proposal_image) } + it { should_not be_able_to(:create, proposal_image) } + it { should_not be_able_to(:destroy, proposal_image) } + + it { should be_able_to(:new, own_budget_investment_image) } + it { should be_able_to(:create, own_budget_investment_image) } + it { should be_able_to(:destroy, own_budget_investment_image) } + + it { should_not be_able_to(:new, budget_investment_image) } + it { should_not be_able_to(:create, budget_investment_image) } + it { should_not be_able_to(:destroy, budget_investment_image) } + describe 'flagging content' do it { should be_able_to(:flag, debate) } it { should be_able_to(:unflag, debate) } @@ -235,33 +256,6 @@ describe "Abilities::Common" do 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(:edit_image, own_investment_in_accepting_budget) } - it { should be_able_to(:edit_image, own_investment_in_reviewing_budget) } - it { should be_able_to(:edit_image, own_investment_in_selecting_budget) } - it { should be_able_to(:edit_image, own_investment_in_balloting_budget) } - it { should be_able_to(:update_image, own_investment_in_accepting_budget) } - it { should be_able_to(:update_image, own_investment_in_reviewing_budget) } - it { should be_able_to(:update_image, own_investment_in_selecting_budget) } - it { should be_able_to(:update_image, own_investment_in_balloting_budget) } - it { should be_able_to(:remove_image, own_investment_in_accepting_budget) } - it { should be_able_to(:remove_image, own_investment_in_reviewing_budget) } - it { should be_able_to(:remove_image, own_investment_in_selecting_budget) } - it { should be_able_to(:remove_image, own_investment_in_balloting_budget) } - - it { should_not be_able_to(:edit_image, investment_in_accepting_budget) } - it { should_not be_able_to(:edit_image, investment_in_reviewing_budget) } - it { should_not be_able_to(:edit_image, investment_in_selecting_budget) } - it { should_not be_able_to(:edit_image, investment_in_balloting_budget) } - it { should_not be_able_to(:update_image, investment_in_accepting_budget) } - it { should_not be_able_to(:update_image, investment_in_reviewing_budget) } - it { should_not be_able_to(:update_image, investment_in_selecting_budget) } - it { should_not be_able_to(:update_image, investment_in_balloting_budget) } - it { should_not be_able_to(:remove_image, investment_in_accepting_budget) } - it { should_not be_able_to(:remove_image, investment_in_reviewing_budget) } - it { should_not be_able_to(:remove_image, investment_in_selecting_budget) } - it { should_not be_able_to(:remove_image, investment_in_balloting_budget) } end end