diff --git a/config/features.rb b/config/features.rb index a95dbbc1a..6f55c3bd1 100644 --- a/config/features.rb +++ b/config/features.rb @@ -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, diff --git a/test/functional/editions_controller_test.rb b/test/functional/editions_controller_test.rb index a447ef2b5..80cf8cab3 100644 --- a/test/functional/editions_controller_test.rb +++ b/test/functional/editions_controller_test.rb @@ -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 @@ -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 @@ -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 diff --git a/test/functional/legacy_editions_controller_test.rb b/test/functional/legacy_editions_controller_test.rb index fd3825d87..30a2e42f8 100644 --- a/test/functional/legacy_editions_controller_test.rb +++ b/test/functional/legacy_editions_controller_test.rb @@ -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 @@ -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 @@ -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 diff --git a/test/models/user_test.rb b/test/models/user_test.rb index f0ddeb71e..5a14a4590 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -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 diff --git a/test/support/factories.rb b/test/support/factories.rb index 81e9df794..f8c06d246 100644 --- a/test/support/factories.rb +++ b/test/support/factories.rb @@ -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