Skip to content

Commit

Permalink
Revert "Merge pull request #2495 from alphagov/enable-permission-rest…
Browse files Browse the repository at this point in the history
…rictions"

This reverts commit 7753720, reversing
changes made to 00b2fe8.

Reverting this change as it is impacting other non-GDS users of Mainstream Publisher that we were unaware of
  • Loading branch information
ellohez committed Jan 17, 2025
1 parent b5b2155 commit ddb2881
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 80 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: true,
default: false,
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
76 changes: 10 additions & 66 deletions test/functional/editions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ 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 related_external_links unpublish].each do |action|
context "##{action}" do
setup do
Expand All @@ -74,6 +64,16 @@ 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 related_external_links unpublish].each do |action|
context "##{action}" do
setup do
Expand Down Expand Up @@ -625,62 +625,6 @@ class EditionsControllerTest < ActionController::TestCase
end
end

context "#update_related_external_links" do
should "display an error message when the title is blank" do
patch :update_related_external_links, params: {
id: @edition.id,
artefact: {
external_links_attributes: [{ title: "", url: "http://foo-bar.com", _destroy: false }],
},
}

assert_equal "External links is invalid", flash[:danger]
end

should "display an error message when the url is blank" do
patch :update_related_external_links, params: {
id: @edition.id,
artefact: {
external_links_attributes: [{ title: "foo", url: "", _destroy: false }],
},
}

assert_equal "External links is invalid", flash[:danger]
end

should "display an error message when the url is invalid" do
patch :update_related_external_links, params: {
id: @edition.id,
artefact: {
external_links_attributes: [{ title: "foo", url: "an-invalid-url", _destroy: false }],
},
}

assert_equal "External links is invalid", flash[:danger]
end

should "update related external links and display a success message when successfully saved" do
patch :update_related_external_links, params: {
id: @edition.id,
artefact: {
external_links_attributes: [{ title: "foo", url: "https://foo-bar.com", _destroy: false }],
},
}

assert_equal "Related links updated.", flash[:success]
assert_equal "foo", @edition.artefact.external_links[0].title
assert_equal "https://foo-bar.com", @edition.artefact.external_links[0].url
end

should "display an error message when there are no external links to save" do
patch :update_related_external_links, params: {
id: @edition.id,
}

assert_equal "There aren't any external related links yet", flash[:danger]
end
end

private

def description(edition)
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, true)
test_strategy.switch!(:restrict_access_by_org, false)
end

context "#create" do
Expand Down Expand Up @@ -1309,16 +1309,6 @@ 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 @@ -1337,6 +1327,16 @@ 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", organisation_content_id: "some-other-org-id")
user = FactoryBot.create(:user, organisation_slug: "some-other-org")

assert_not user.gds_editor?
end
Expand Down
1 change: 0 additions & 1 deletion test/support/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
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 ddb2881

Please sign in to comment.