Add cancancan to SDG content

Only allow access to the SDG content section to administrators and sdg managers
This commit is contained in:
taitus
2020-11-25 15:00:01 +01:00
committed by Javi Martín
parent 65d6282b51
commit fb5965fe63
14 changed files with 52 additions and 5 deletions

View File

@@ -106,4 +106,7 @@ describe Abilities::Administrator do
it { should be_able_to(:manage, LocalCensusRecord) }
it { should be_able_to(:create, LocalCensusRecords::Import) }
it { should be_able_to(:show, LocalCensusRecords::Import) }
it { should be_able_to(:read, SDG::Goal) }
it { should be_able_to(:read, SDG::Target) }
end

View File

@@ -304,4 +304,7 @@ describe Abilities::Common do
it { should be_able_to(:disable_recommendations, Debate) }
it { should be_able_to(:disable_recommendations, Proposal) }
end
it { should_not be_able_to(:read, SDG::Goal) }
it { should_not be_able_to(:read, SDG::Target) }
end

View File

@@ -52,4 +52,7 @@ describe Abilities::Everyone do
it { should be_able_to(:summary, create(:legislation_process, :past)) }
it { should_not be_able_to(:summary, create(:legislation_process, :open)) }
it { should_not be_able_to(:summary, create(:legislation_process, :past, :not_published)) }
it { should_not be_able_to(:read, SDG::Goal) }
it { should_not be_able_to(:read, SDG::Target) }
end

View File

@@ -108,4 +108,7 @@ describe Abilities::Moderator do
it { should_not be_able_to(:comment_as_administrator, proposal) }
it { should_not be_able_to(:comment_as_administrator, legislation_question) }
end
it { should_not be_able_to(:read, SDG::Goal) }
it { should_not be_able_to(:read, SDG::Target) }
end

View File

@@ -22,4 +22,7 @@ describe "Abilities::Organization" do
it { should be_able_to(:create, Comment) }
it { should_not be_able_to(:vote, Comment) }
it { should_not be_able_to(:read, SDG::Goal) }
it { should_not be_able_to(:read, SDG::Target) }
end

View File

@@ -0,0 +1,12 @@
require "rails_helper"
require "cancan/matchers"
describe "Abilities::SDG::Manager" do
subject(:ability) { Ability.new(user) }
let(:user) { sdg_manager.user }
let(:sdg_manager) { create(:sdg_manager) }
it { should be_able_to(:read, SDG::Goal) }
it { should be_able_to(:read, SDG::Target) }
end

View File

@@ -39,4 +39,7 @@ describe Abilities::Valuator do
it { should_not be_able_to(:comment_valuation, assigned_investment) }
end
it { should_not be_able_to(:read, SDG::Goal) }
it { should_not be_able_to(:read, SDG::Target) }
end