From ef20ccd454f982b44aac3e4a9a221a04b99c6a15 Mon Sep 17 00:00:00 2001 From: JP <85654561+jp524@users.noreply.github.com> Date: Wed, 22 May 2024 15:45:23 -0500 Subject: [PATCH] Remove 'My Organization' link for superadmins that are also org admins --- app/views/layouts/_lte_admin_sidebar.html.erb | 9 ------ app/views/layouts/_lte_navbar.html.erb | 3 +- spec/system/admin/dashboard_system_spec.rb | 30 ------------------- spec/system/navigation_system_spec.rb | 2 +- 4 files changed, 2 insertions(+), 42 deletions(-) delete mode 100644 spec/system/admin/dashboard_system_spec.rb diff --git a/app/views/layouts/_lte_admin_sidebar.html.erb b/app/views/layouts/_lte_admin_sidebar.html.erb index 8a78402327..2679b59345 100644 --- a/app/views/layouts/_lte_admin_sidebar.html.erb +++ b/app/views/layouts/_lte_admin_sidebar.html.erb @@ -139,13 +139,4 @@ <% end %> - <% if (current_user.organization.present?) %> - - <% end %> - diff --git a/app/views/layouts/_lte_navbar.html.erb b/app/views/layouts/_lte_navbar.html.erb index 47d4a8fc20..f2abf12076 100644 --- a/app/views/layouts/_lte_navbar.html.erb +++ b/app/views/layouts/_lte_navbar.html.erb @@ -50,8 +50,7 @@ <%= "Switch to: #{role.resource&.name || "Super Admin"}" %> <% end %> <% end %> - <% if current_organization.id.present? && - (current_user.has_role?(Role::SUPER_ADMIN) || current_user.has_role?(Role::ORG_ADMIN, current_organization)) %> + <% if current_user.has_role?(Role::ORG_ADMIN, current_organization) %> <%= link_to users_path, class:"dropdown-item" do %> My Co-Workers diff --git a/spec/system/admin/dashboard_system_spec.rb b/spec/system/admin/dashboard_system_spec.rb deleted file mode 100644 index 9c0b2c4c21..0000000000 --- a/spec/system/admin/dashboard_system_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -RSpec.describe "Dashboard", type: :system, js: true do - subject { admin_dashboard_path } - let(:organization) { create(:organization) } - let(:super_admin) { create(:super_admin, organization: organization) } - - context "When the super admin user also has an organization assigned" do - before do - super_admin.add_role(Role::ORG_USER, organization) - sign_in(super_admin) - visit subject - end - - it "displays a link to return to their organization" do - expect(page).to have_link("My Organization") - end - end - - context "When the super admin user does not have an organization assigned" do - before do - super_admin.remove_role(Role::ORG_USER, organization) - super_admin.save - sign_in(super_admin) - visit subject - end - - it "DOES NOT have a link to the organization" do - expect(page).not_to have_link("My Organization") - end - end -end diff --git a/spec/system/navigation_system_spec.rb b/spec/system/navigation_system_spec.rb index 337e1ac7a6..b28a7b47c3 100644 --- a/spec/system/navigation_system_spec.rb +++ b/spec/system/navigation_system_spec.rb @@ -63,7 +63,7 @@ context "with superadmin user" do let(:user) { create(:super_admin) } - let(:links) { ["Admin Dashboard", "Barcode Items", "Base Items", "Organizations", "Partners", "Users", "Announcements", "Account Requests", "FAQ", "My Organization"] } + let(:links) { ["Admin Dashboard", "Barcode Items", "Base Items", "Organizations", "Partners", "Users", "Announcements", "Account Requests", "FAQ"] } it "shows navigation options" do sidebar = page.find(".sidebar")