Skip to content

Commit

Permalink
Add "Republish content" to "More" page
Browse files Browse the repository at this point in the history
This is only visible to users with GDS admin permissions
  • Loading branch information
yndajas committed May 9, 2024
1 parent c87ec5c commit 6cee7c0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/helpers/admin/url_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ def admin_header_link(name, path, path_matcher = nil, options = {})
end
end

def admin_republish_content_link
if can?(:administer, :republish_content)
admin_link "Republish content", admin_republishing_index_path
end
end

private

def active_link_class(path_matcher)
Expand Down
1 change: 1 addition & 0 deletions app/views/admin/more/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
admin_topical_events_link,
admin_world_location_news_link,
admin_worldwide_organisations_link,
admin_republish_content_link,
],
} %>
</div>
Expand Down
20 changes: 20 additions & 0 deletions test/functional/admin/more_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,24 @@ class Admin::MoreControllerTest < ActionController::TestCase
assert_select ".govuk-list"
assert_select "a.govuk-link", text: "Emergency banner"
end

view_test "GET #index does not render Republish content option when the user is not a GDS Admin." do
organisation = create(:organisation, name: "cabinet-minister")
login_as(:writer, organisation)

get :index

assert_select ".govuk-list"
refute_select "a.govuk-link", text: "Republish content"
end

view_test "GET #index renders Republish content option when the user is a GDS Admin." do
organisation = create(:organisation, name: "government-digital-service")
login_as(:gds_admin, organisation)

get :index

assert_select ".govuk-list"
assert_select "a.govuk-link", text: "Republish content"
end
end

0 comments on commit 6cee7c0

Please sign in to comment.