From a78f9fa04fe9a7d76e9af22b1eda8c593b2961bd Mon Sep 17 00:00:00 2001 From: Mark Taylor <138604938+mtaylorgds@users.noreply.github.com> Date: Fri, 14 Jul 2023 14:36:01 +0100 Subject: [PATCH] Only show link to What's new page for limited time 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). --- app/helpers/navigation_helper.rb | 7 ++-- spec/helpers/navigation_helper_spec.rb | 46 ++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb index e05606658..7a7021985 100644 --- a/app/helpers/navigation_helper.rb +++ b/app/helpers/navigation_helper.rb @@ -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 diff --git a/spec/helpers/navigation_helper_spec.rb b/spec/helpers/navigation_helper_spec.rb index 64aa36f67..9b0fd8d11 100644 --- a/spec/helpers/navigation_helper_spec.rb +++ b/spec/helpers/navigation_helper_spec.rb @@ -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