Skip to content

Commit

Permalink
Merge pull request #2495 from alphagov/enable-permission-restrictions
Browse files Browse the repository at this point in the history
Change default to true for restrict_access_by_org feature
  • Loading branch information
baisa authored Jan 15, 2025
2 parents 00b2fe8 + 85d83aa commit 7753720
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion config/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
description: "Update the publications edit page to use the GOV.UK Design System"

feature :restrict_access_by_org,
default: false,
default: true,
description: "Restrict access to editions based on the user's org and which org(s) own the edition"

feature :show_link_to_content_block_manager,
Expand Down
22 changes: 11 additions & 11 deletions test/functional/editions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class EditionsControllerTest < ActionController::TestCase
setup do
login_as_stub_user
test_strategy = Flipflop::FeatureSet.current.test!
test_strategy.switch!(:restrict_access_by_org, false)
test_strategy.switch!(:restrict_access_by_org, true)
@edition = FactoryBot.create(:edition, :fact_check)
@welsh_edition = FactoryBot.create(:edition, :fact_check, :welsh)
end
Expand Down Expand Up @@ -46,6 +46,16 @@ class EditionsControllerTest < ActionController::TestCase
end

context "when 'restrict_access_by_org' feature toggle is disabled" do
setup do
test_strategy = Flipflop::FeatureSet.current.test!
test_strategy.switch!(:restrict_access_by_org, false)
end

teardown do
test_strategy = Flipflop::FeatureSet.current.test!
test_strategy.switch!(:restrict_access_by_org, true)
end

%i[show metadata history admin linking unpublish].each do |action|
context "##{action}" do
setup do
Expand All @@ -64,16 +74,6 @@ class EditionsControllerTest < ActionController::TestCase
end

context "when 'restrict_access_by_org' feature toggle is enabled" do
setup do
test_strategy = Flipflop::FeatureSet.current.test!
test_strategy.switch!(:restrict_access_by_org, true)
end

teardown do
test_strategy = Flipflop::FeatureSet.current.test!
test_strategy.switch!(:restrict_access_by_org, false)
end

%i[show metadata history admin linking unpublish].each do |action|
context "##{action}" do
setup do
Expand Down
22 changes: 11 additions & 11 deletions test/functional/legacy_editions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class LegacyEditionsControllerTest < ActionController::TestCase
stub_holidays_used_by_fact_check

test_strategy = Flipflop::FeatureSet.current.test!
test_strategy.switch!(:restrict_access_by_org, false)
test_strategy.switch!(:restrict_access_by_org, true)
end

context "#create" do
Expand Down Expand Up @@ -1309,6 +1309,16 @@ class LegacyEditionsControllerTest < ActionController::TestCase
end

context "when 'restrict_access_by_org' feature toggle is disabled" do
setup do
test_strategy = Flipflop::FeatureSet.current.test!
test_strategy.switch!(:restrict_access_by_org, false)
end

teardown do
test_strategy = Flipflop::FeatureSet.current.test!
test_strategy.switch!(:restrict_access_by_org, true)
end

%i[metadata history].each do |action|
context "##{action}" do
setup do
Expand All @@ -1327,16 +1337,6 @@ class LegacyEditionsControllerTest < ActionController::TestCase
end

context "when 'restrict_access_by_org' feature toggle is enabled" do
setup do
test_strategy = Flipflop::FeatureSet.current.test!
test_strategy.switch!(:restrict_access_by_org, true)
end

teardown do
test_strategy = Flipflop::FeatureSet.current.test!
test_strategy.switch!(:restrict_access_by_org, false)
end

%i[show metadata history admin unpublish duplicate update linking update_tagging update_related_external_links review destroy progress diff process_unpublish diagram].each do |action|
context "##{action}" do
setup do
Expand Down
2 changes: 1 addition & 1 deletion test/models/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def setup
end

test "#gds_editor? is false if user's organisation is not GDS" do
user = FactoryBot.create(:user, organisation_slug: "some-other-org")
user = FactoryBot.create(:user, organisation_slug: "some-other-org", organisation_content_id: "some-other-org-id")

assert_not user.gds_editor?
end
Expand Down
1 change: 1 addition & 0 deletions test/support/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
sequence(:uid) { |n| "uid-#{n}" }
sequence(:name) { |n| "Joe Bloggs #{n}" }
sequence(:email) { |n| "joe#{n}@bloggs.com" }
organisation_content_id { PublishService::GDS_ORGANISATION_ID }

if defined?(GDS::SSO::Config)
# Grant permission to signin to the app using the gem
Expand Down

0 comments on commit 7753720

Please sign in to comment.