diff --git a/spec/helpers/navigation_items_helper_spec.rb b/spec/helpers/navigation_items_helper_spec.rb index 779c8d2da..085887265 100644 --- a/spec/helpers/navigation_items_helper_spec.rb +++ b/spec/helpers/navigation_items_helper_spec.rb @@ -7,7 +7,62 @@ 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 "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 "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 + [ + NavigationItemsHelper::NavigationItem.new("Logs", "/logs", true), + NavigationItemsHelper::NavigationItem.new("Users", users_path, false), + NavigationItemsHelper::NavigationItem.new("About your organisation", organisation_path, false), + ] + end + + it "returns navigation items with the users item set as current" do + expect(primary_items("/logs", current_user)).to eq(expected_navigation_items) + end + end + context "when the user is on the users page" do let(:expected_navigation_items) do [