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 14, 2023
1 parent 2f744e5 commit a78f9fa
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 9 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.push({ text: "What's new", href: whats_new_path, active: request.path == whats_new_path })
end
links
end

def navigation_links_auth
Expand Down
46 changes: 39 additions & 7 deletions spec/helpers/navigation_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,48 @@
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
describe "before the what's new page expires" do
before do
travel_to Date.new(2023, 10, 31)
end

after do
travel_back
end

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
expect(navigation_links_internal).to include(a_hash_including(text: "Manuals", href: manuals_path))
end

it "includes a link to manuals" do
expect(navigation_links_internal).to include(a_hash_including(text: "Manuals", href: manuals_path))
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))
end
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))
describe "once the what's new page expires" do
before do
travel_to Date.new(2023, 11, 1)
end

after do
travel_back
end

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
expect(navigation_links_internal).to include(a_hash_including(text: "Manuals", href: manuals_path))
end

it "does not include a link to what's new" do
expect(navigation_links_internal).not_to include(a_hash_including(text: "What's new", href: whats_new_path))
end
end

it "sets the link to the current page as active" do
Expand Down

0 comments on commit a78f9fa

Please sign in to comment.