From b2210d3107dda8363af49e83c20ad70ebb794ad6 Mon Sep 17 00:00:00 2001 From: Ted-U Date: Mon, 8 Aug 2022 13:13:37 +0100 Subject: [PATCH] only stock owning orgs see schemes in nav bar --- app/helpers/navigation_items_helper.rb | 2 +- spec/features/organisation_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/helpers/navigation_items_helper.rb b/app/helpers/navigation_items_helper.rb index dbaf64296..4bf5a5fec 100644 --- a/app/helpers/navigation_items_helper.rb +++ b/app/helpers/navigation_items_helper.rb @@ -9,7 +9,7 @@ module NavigationItemsHelper NavigationItem.new("Logs", case_logs_path, logs_current?(path)), NavigationItem.new("Schemes", "/schemes", supported_housing_schemes_current?(path)), ] - elsif current_user.data_coordinator? + elsif current_user.data_coordinator? && current_user.organisation.holds_own_stock? [ NavigationItem.new("Logs", case_logs_path, logs_current?(path)), NavigationItem.new("Schemes", "/schemes", subnav_supported_housing_schemes_path?(path)), diff --git a/spec/features/organisation_spec.rb b/spec/features/organisation_spec.rb index 118638d84..697889c77 100644 --- a/spec/features/organisation_spec.rb +++ b/spec/features/organisation_spec.rb @@ -39,6 +39,21 @@ RSpec.describe "User Features" do click_link("About your organisation") expect(page).to have_current_path("/organisations/#{org_id}/details") end + + context "when the user is a coordinator and the organisation holds housing stock" do + let(:organisation) { FactoryBot.create(:organisation, holds_own_stock: true) } + it "shows schemes in the navigation bar" do + visit("/logs") + expect(page).to have_link("Schemes", href: "/schemes") + end + end + context "when the user is a coordinator and the organisation does not hold housing stock" do + let(:organisation) { FactoryBot.create(:organisation, holds_own_stock: false) } + it "does not show schemes in the navigation bar" do + visit("/logs") + expect(page).to_not have_link("Schemes", href: "/schemes") + end + end end context "when users are part of organisation" do