Skip to content

Commit

Permalink
Only show link to What's new page for limited time
Browse files Browse the repository at this point in the history
Since we're only updating the manuals publisher app for a limited period of time, the "what's new" page won't be relevant for long, so don't show the link to it after the 1st November 2023. The page will still be there, it just won't be navigatable to without knowing the page path. Future work could/should remove the page completely (or restore the link to it if it becomes relevant again).
  • Loading branch information
mtaylorgds committed Jul 19, 2023
1 parent 6ce678b commit e88f943
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
7 changes: 5 additions & 2 deletions app/helpers/navigation_helper.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
module NavigationHelper
def navigation_links_internal
[
links = [
{ text: "Manuals", href: manuals_path, active: request.path == manuals_path },
{ text: "What's new", href: whats_new_path, active: request.path == whats_new_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 }
end
links
end

def navigation_links_auth
Expand Down
26 changes: 11 additions & 15 deletions spec/helpers/navigation_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
require "spec_helper"
describe NavigationHelper, type: :helper do
describe "#navigation_links_internal" do
it "returns a list of internal links" do
expect(navigation_links_internal).to be_an_instance_of(Array)
end

it "includes a link to manuals" do
it "returns a link to the manuals page" do
expect(navigation_links_internal).to include(a_hash_including(text: "Manuals", href: manuals_path))
end

it "includes a link to what's new" do
expect(navigation_links_internal).to include(a_hash_including(text: "What's new", href: whats_new_path))
it "toggles a what's new link based on whether it is before or after November 2023" do
whats_new = a_hash_including(text: "What's new", href: whats_new_path)

travel_to(Date.new(2023, 10, 31)) do
expect(navigation_links_internal).to include(whats_new)
end

travel_to(Date.new(2023, 11, 1)) do
expect(navigation_links_internal).not_to include(whats_new)
end
end

it "sets the link to the current page as active" do
request.path = manuals_path
expect(navigation_links_internal).to include(a_hash_including(text: "Manuals", active: true))
expect(navigation_links_internal).to include(a_hash_including(text: "What's new", active: false))
end
end

describe "#navigation_links_auth" do
let(:current_user) { User.create!(name: "John Doe") }

it "returns a list of auth links" do
expect(navigation_links_auth).to be_an_instance_of(Array)
end

it "includes a link to the user's profile" do
expect(navigation_links_auth).to include(
a_hash_including(text: "John Doe", href: Plek.external_url_for("signon")),
)
end

it "includes a link to sign out" do
expect(navigation_links_auth).to include(
a_hash_including(text: "Log out", href: gds_sign_out_path),
)
Expand Down

0 comments on commit e88f943

Please sign in to comment.