From 27c9a519772b1a62b1b9c75f9f70ede57d4ddf05 Mon Sep 17 00:00:00 2001 From: HazelGrant Date: Tue, 9 Apr 2024 09:54:55 -0400 Subject: [PATCH] Small refactor --- .../app/models/user_configuration.rb | 9 +-- .../integration/dashboard_controller_test.rb | 71 ------------------- 2 files changed, 3 insertions(+), 77 deletions(-) diff --git a/apps/dashboard/app/models/user_configuration.rb b/apps/dashboard/app/models/user_configuration.rb index 16abc7182a..565ebb4b40 100644 --- a/apps/dashboard/app/models/user_configuration.rb +++ b/apps/dashboard/app/models/user_configuration.rb @@ -122,17 +122,14 @@ def announcement_path end end - CATEGORIES = ["Apps", "Files", "Jobs", "Clusters", "Interactive Apps"].freeze - CATEGORIES_WHITELIST = false + DEFAULT_NAV_CATEGORIES = ["Apps", "Files", "Jobs", "Clusters", "Interactive Apps"].freeze - # Filtering is controlled with NavConfig.categories_allowlist? unless the configuration property categories is defined. - # If categories are defined, filter_nav_categories? will always be true. def filter_nav_categories? - fetch(:nav_categories, nil).nil? ? CATEGORIES_WHITELIST : true + fetch(:nav_categories, nil) end def nav_categories - fetch(:nav_categories, nil) || CATEGORIES + fetch(:nav_categories, DEFAULT_NAV_CATEGORIES) end # Create support ticket service class based on the configuration diff --git a/apps/dashboard/test/integration/dashboard_controller_test.rb b/apps/dashboard/test/integration/dashboard_controller_test.rb index e6e3301c51..c3863e315a 100644 --- a/apps/dashboard/test/integration/dashboard_controller_test.rb +++ b/apps/dashboard/test/integration/dashboard_controller_test.rb @@ -147,53 +147,6 @@ def teardown assert_response :success assert_select "nav a[href='#{batch_connect_sessions_path}']", 0 end -=begin - test 'should not create app menus if NavConfig.categories is empty and whitelist is enabled' do - SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps')) - OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d')) - NavConfig.stubs(:categories_whitelist?).returns(true) - NavConfig.stubs(:categories).returns([]) - - get root_path - assert_response :success - assert_select dropdown_links, 1 # +1 here is 'Help' - assert_select dropdown_link(1), text: 'Help' # ensure is Help - end -=end -=begin - test 'should exclude gateway apps if NavConfig.categories is set to default and whitelist is enabled' do - SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps')) - OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d')) - NavConfig.stubs(:categories_whitelist?).returns(true) - NavConfig.stubs(:categories).returns(['Files', 'Jobs', 'Clusters', 'Interactive Apps']) - - get root_path - assert_response :success - assert_select dropdown_links, 5 # +1 here is 'Help' - assert_select dropdown_link(1), text: 'Files' - assert_select dropdown_link(2), text: 'Jobs' - assert_select dropdown_link(3), text: 'Clusters' - assert_select dropdown_link(4), text: 'Interactive Apps' - assert_select dropdown_link(5), text: 'Help' - end -=end -=begin - test 'uses NavConfig.categories as sort order if whitelist is false' do - SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps')) - OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d')) - NavConfig.stubs(:categories_whitelist?).returns(false) - NavConfig.stubs(:categories).returns(['Jobs', 'Interactive Apps', 'Files', 'Clusters']) - - get root_path - assert_response :success - assert_select dropdown_links, 6 # +1 here is 'Help' - assert_select dropdown_link(1), text: 'Jobs' - assert_select dropdown_link(2), text: 'Interactive Apps' - assert_select dropdown_link(3), text: 'Files' - assert_select dropdown_link(4), text: 'Clusters' - assert_select dropdown_link(5), text: 'Gateway Apps' - end -=end test 'UserConfiguration.categories should filter and order the navigation' do SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps')) @@ -224,30 +177,6 @@ def teardown assert_select dropdown_links, 1 # +1 here is 'Help' assert_select dropdown_link(1), text: 'Help' # ensure is Help end -=begin - test 'verify default values for NavConfig' do - refute NavConfig.categories_whitelist? - assert NavConfig - end -=end -=begin - test 'display all app menus in alphabetical order if NavConfig.whitelist false & NavConfig.categories nil or []' do - SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps')) - OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d')) - NavConfig.stubs(:categories_whitelist?).returns(false) - NavConfig.stubs(:categories).returns([]) - - get root_path - assert_response :success - assert_select dropdown_links, 6 # +1 here is 'Help' - - assert_select dropdown_link(1), text: 'Clusters' - assert_select dropdown_link(2), text: 'Files' - assert_select dropdown_link(3), text: 'Gateway Apps' - assert_select dropdown_link(4), text: 'Interactive Apps' - assert_select dropdown_link(5), text: 'Jobs' - end -=end test 'apps with no category should not appear in menu' do SysRouter.stubs(:base_path).returns(Rails.root.join('test/fixtures/sys_with_gateway_apps'))