Skip to content

Commit

Permalink
Hide support navigation items from unauthorised users
Browse files Browse the repository at this point in the history
  • Loading branch information
steventux committed Dec 6, 2023
1 parent 4a5d6f1 commit 5648b14
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
20 changes: 10 additions & 10 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ def navigation
govuk_header(service_name: t("service.name")) do |header|
case current_namespace
when "support"
header.with_navigation_item(
active: current_page?(main_app.support_interface_feature_flags_path),
href: main_app.support_interface_feature_flags_path,
text: "Features"
)
header.with_navigation_item(
active: request.path.start_with?("/support/staff"),
text: "Staff",
href: main_app.support_interface_staff_index_path
)
if current_staff
header.with_navigation_item(
active: current_page?(main_app.support_interface_feature_flags_path),
href: main_app.support_interface_feature_flags_path,
text: "Features"
)
header.with_navigation_item(
active: request.path.start_with?("/support/staff"),
text: "Staff",
href: main_app.support_interface_staff_index_path
)
header.with_navigation_item(href: main_app.support_interface_sign_out_path, text: "Sign out")
end
when "qualifications"
Expand Down
6 changes: 5 additions & 1 deletion spec/system/support/staff_user_signs_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
private

def then_i_am_signed_in
within("header") { expect(page).to have_content "Sign out" }
within("header") do
expect(page).to have_link("Features")
expect(page).to have_link("Staff")
expect(page).to have_content "Sign out"
end
expect(DsiUser.count).to eq 1
expect(DsiUserSession.count).to eq 1
end
Expand Down
2 changes: 2 additions & 0 deletions spec/system/support/unauthorised_user_signs_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def then_i_am_redirected_to_the_unauthorised_page
expect(page).to have_link("sign out and start again", href: "/support/auth/staff/sign-out?id_token_hint=abc123")

within(".govuk-header__content") do
expect(page).not_to have_link("Features")
expect(page).not_to have_link("Staff")
expect(page).not_to have_link("Sign in")
expect(page).not_to have_link("Sign out")
end
Expand Down

0 comments on commit 5648b14

Please sign in to comment.