diff --git a/app/components/primary_navigation_component.rb b/app/components/primary_navigation_component.rb index 0389d30b3..e766a83ce 100644 --- a/app/components/primary_navigation_component.rb +++ b/app/components/primary_navigation_component.rb @@ -3,6 +3,7 @@ class PrimaryNavigationComponent < ViewComponent::Base def initialize(items:) @items = items + Rails.env.production? ? @items = @items.reject { |nav_item| nav_item.text.include?("Supported housing") } : @items super end diff --git a/spec/components/primary_navigation_component_spec.rb b/spec/components/primary_navigation_component_spec.rb index 0de1c58d1..9a3c91d09 100644 --- a/spec/components/primary_navigation_component_spec.rb +++ b/spec/components/primary_navigation_component_spec.rb @@ -6,6 +6,7 @@ RSpec.describe PrimaryNavigationComponent, type: :component do NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", true), NavigationItemsHelper::NavigationItem.new("Users", "/users", false), NavigationItemsHelper::NavigationItem.new("Logs ", "/logs", false), + NavigationItemsHelper::NavigationItem.new("Supported housing", "/supported-housing", false), ] end @@ -24,6 +25,7 @@ RSpec.describe PrimaryNavigationComponent, type: :component do expect(navigation_panel).to be_highlighted_item(items[0], "/something-else") expect(navigation_panel).not_to be_highlighted_item(items[1], "/something-else") expect(navigation_panel).not_to be_highlighted_item(items[2], "/something-else") + expect(navigation_panel).not_to be_highlighted_item(items[3], "/something-else") end end @@ -34,6 +36,18 @@ RSpec.describe PrimaryNavigationComponent, type: :component do expect(result.text).to include("Organisations") expect(result.text).to include("Users") expect(result.text).to include("Logs") + expect(result.text).to include("Supported housing") + end + end + + context "when production environment" do + before do + allow(Rails.env).to receive(:production?).and_return(true) + end + + it "doesn't render supported housing" do + result = render_inline(described_class.new(items:)) + expect(result.text).not_to include("Supported housing") end end end