From 8123ec5ab2a913fcb38958d6b848b46216ad5e8b Mon Sep 17 00:00:00 2001 From: Ted-U Date: Mon, 22 Aug 2022 13:26:25 +0100 Subject: [PATCH] removed schemes from secondary navigation bar for non stock owning orgs --- app/helpers/navigation_items_helper.rb | 20 ++++++++++++++------ spec/features/organisation_spec.rb | 12 ++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/app/helpers/navigation_items_helper.rb b/app/helpers/navigation_items_helper.rb index 4bf5a5fec..e55aeeb77 100644 --- a/app/helpers/navigation_items_helper.rb +++ b/app/helpers/navigation_items_helper.rb @@ -26,12 +26,20 @@ module NavigationItemsHelper end def secondary_items(path, current_organisation_id) - [ - NavigationItem.new("Logs", "/organisations/#{current_organisation_id}/logs", subnav_logs_path?(path)), - NavigationItem.new("Schemes", "/organisations/#{current_organisation_id}/schemes", subnav_supported_housing_schemes_path?(path)), - NavigationItem.new("Users", "/organisations/#{current_organisation_id}/users", subnav_users_path?(path)), - NavigationItem.new("About this organisation", "/organisations/#{current_organisation_id}", subnav_details_path?(path)), - ] + if current_user.organisation.holds_own_stock? + [ + NavigationItem.new("Logs", "/organisations/#{current_organisation_id}/logs", subnav_logs_path?(path)), + NavigationItem.new("Schemes", "/organisations/#{current_organisation_id}/schemes", subnav_supported_housing_schemes_path?(path)), + NavigationItem.new("Users", "/organisations/#{current_organisation_id}/users", subnav_users_path?(path)), + NavigationItem.new("About this organisation", "/organisations/#{current_organisation_id}", subnav_details_path?(path)), + ] + else + [ + NavigationItem.new("Logs", "/organisations/#{current_organisation_id}/logs", subnav_logs_path?(path)), + NavigationItem.new("Users", "/organisations/#{current_organisation_id}/users", subnav_users_path?(path)), + NavigationItem.new("About this organisation", "/organisations/#{current_organisation_id}", subnav_details_path?(path)), + ] + end end def scheme_items(path, current_scheme_id, title) diff --git a/spec/features/organisation_spec.rb b/spec/features/organisation_spec.rb index d034468dd..1798b5d3c 100644 --- a/spec/features/organisation_spec.rb +++ b/spec/features/organisation_spec.rb @@ -61,6 +61,18 @@ RSpec.describe "User Features" do expect(page).to have_link("Schemes", href: "/schemes") end end + + context "when the user is support and the organisation does not hold housing stock" do + before do + organisation.update!(holds_own_stock: false) + user.update!(role: "support") + end + + it "does not show schemes in the primary or secondary navigation bar on the organisations page" do + visit("/organisations") + expect(page).not_to have_link("Schemes", href: "/schemes", count: 2) + end + end end context "when users are part of organisation" do