From a9742225f84f0008f3ff0a40e87e7c3e7204d1ef Mon Sep 17 00:00:00 2001 From: Mark Taylor <138604938+mtaylorgds@users.noreply.github.com> Date: Thu, 24 Aug 2023 16:24:06 +0100 Subject: [PATCH] Highlight the "Manuals" header link on manual pages Looking at how other apps work (e.g. Travel Advice Publisher) the "Manuals" link should be active when on any of the pages under `/manuals`. --- app/helpers/navigation_helper.rb | 2 +- spec/helpers/navigation_helper_spec.rb | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb index 1252fe234..a3211495a 100644 --- a/app/helpers/navigation_helper.rb +++ b/app/helpers/navigation_helper.rb @@ -1,7 +1,7 @@ module NavigationHelper def navigation_links_internal links = [ - { text: "Manuals", href: manuals_path, active: request.path == manuals_path }, + { text: "Manuals", href: manuals_path, active: request.path.starts_with?(manuals_path) }, ] if Time.zone.today < Date.new(2023, 11, 1) links << { text: "What's new", href: whats_new_path, active: request.path == whats_new_path } diff --git a/spec/helpers/navigation_helper_spec.rb b/spec/helpers/navigation_helper_spec.rb index 5162b08c3..0c801e5a9 100644 --- a/spec/helpers/navigation_helper_spec.rb +++ b/spec/helpers/navigation_helper_spec.rb @@ -17,10 +17,16 @@ end end - it "sets the link to the current page as active" do + it "sets the link to the manuals page as active when on the manuals index page" do request.path = manuals_path expect(navigation_links_internal).to include(a_hash_including(text: "Manuals", active: true)) end + + it "sets the link to the manuals page as active when on a manual's view page" do + manual = FactoryBot.build_stubbed(:manual) + request.path = manual_path(manual) + expect(navigation_links_internal).to include(a_hash_including(text: "Manuals", active: true)) + end end describe "#navigation_links_auth" do