Skip to content

Commit

Permalink
Merge pull request #2143 from alphagov/consolidation-navbar-manuals-h…
Browse files Browse the repository at this point in the history
…ighlight

Highlight the "Manuals" header link on manual pages
  • Loading branch information
ryanb-gds authored Aug 29, 2023
2 parents 82a0c14 + a974222 commit b823d38
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/helpers/navigation_helper.rb
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
8 changes: 7 additions & 1 deletion spec/helpers/navigation_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b823d38

Please sign in to comment.