From 7cae12b36c7b3f2a6a0d5528fad383388e6e259a Mon Sep 17 00:00:00 2001 From: JG Date: Thu, 9 Jun 2022 08:57:19 +0100 Subject: [PATCH] moved toggle to a different place --- app/helpers/navigation_items_helper.rb | 12 ++++-- spec/helpers/navigation_items_helper_spec.rb | 41 -------------------- 2 files changed, 9 insertions(+), 44 deletions(-) diff --git a/app/helpers/navigation_items_helper.rb b/app/helpers/navigation_items_helper.rb index d4f5d1559..bdc755faf 100644 --- a/app/helpers/navigation_items_helper.rb +++ b/app/helpers/navigation_items_helper.rb @@ -2,15 +2,21 @@ module NavigationItemsHelper NavigationItem = Struct.new(:text, :href, :current, :classes) def primary_items(path, current_user) + nav_items = [] if current_user.support? - nav_items = [ + [ NavigationItem.new("Organisations", organisations_path, organisations_current?(path)), NavigationItem.new("Users", "/users", users_current?(path)), NavigationItem.new("Logs", case_logs_path, logs_current?(path)), NavigationItem.new("Supported housing", "/supported-housing", supported_housing_current?(path)), ] - - Rails.env.production? ? nav_items[0...-1] : nav_items + elsif current_user.data_coordinator? + [ + NavigationItem.new("Logs", case_logs_path, logs_current?(path)), + NavigationItem.new("Supported housing", "/supported-housing", supported_housing_current?(path)), + NavigationItem.new("Users", users_organisation_path(current_user.organisation), subnav_users_path?(path)), + NavigationItem.new("About your organisation", "/organisations/#{current_user.organisation.id}", subnav_details_path?(path)), + ] else [ NavigationItem.new("Logs", case_logs_path, logs_current?(path)), diff --git a/spec/helpers/navigation_items_helper_spec.rb b/spec/helpers/navigation_items_helper_spec.rb index 6456362b4..0d138fe9b 100644 --- a/spec/helpers/navigation_items_helper_spec.rb +++ b/spec/helpers/navigation_items_helper_spec.rb @@ -7,47 +7,6 @@ RSpec.describe NavigationItemsHelper do let(:organisation_path) { "/organisations/#{current_user.organisation.id}" } describe "#primary items" do - context "when production environment" do - let(:expected_navigation_items) do - [ - NavigationItemsHelper::NavigationItem.new("Logs", "/logs", true), - NavigationItemsHelper::NavigationItem.new("Users", users_path, false), - NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false), - ] - end - - before do - allow(Rails.env).to receive(:production?).and_return(true) - end - - it "data coordinator user can't see the link to supported housing" do - expect(primary_items("/logs", current_user)).to eq(expected_navigation_items) - end - - context "data provider user" do - let(:current_user) { FactoryBot.create(:user) } - - it "data provider user can't see the link to supported housing" do - expect(primary_items("/logs", current_user)).to eq(expected_navigation_items) - end - end - - context "support user" do - let(:expected_navigation_items) do - [ - NavigationItemsHelper::NavigationItem.new("Organisations", "/organisations", false), - NavigationItemsHelper::NavigationItem.new("Users", "/users", false), - NavigationItemsHelper::NavigationItem.new("Logs", "/logs", true), - ] - end - let(:current_user) { FactoryBot.create(:user, :support) } - - it "support user can't see the link to supported housing" do - expect(primary_items("/logs", current_user)).to eq(expected_navigation_items) - end - end - end - context "when the user is a data coordinator" do context "when the user is on the logs page" do let(:expected_navigation_items) do