Skip to content

Commit

Permalink
Removes NavConfig & associated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HazelGrant committed Apr 9, 2024
1 parent bee9186 commit d554aec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
7 changes: 5 additions & 2 deletions apps/dashboard/app/models/user_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,17 @@ def announcement_path
end
end

CATEGORIES = ["Apps", "Files", "Jobs", "Clusters", "Interactive Apps"].freeze
CATEGORIES_WHITELIST = false

# 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? ? NavConfig.categories_whitelist? : true
fetch(:nav_categories, nil).nil? ? CATEGORIES_WHITELIST : true
end

def nav_categories
fetch(:nav_categories, nil) || NavConfig.categories
fetch(:nav_categories, nil) || CATEGORIES
end

# Create support ticket service class based on the configuration
Expand Down
22 changes: 11 additions & 11 deletions apps/dashboard/test/integration/dashboard_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ 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'))
Expand All @@ -159,7 +159,8 @@ def teardown
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'))
Expand All @@ -175,7 +176,8 @@ def teardown
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'))
Expand All @@ -191,12 +193,11 @@ def teardown
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 and have precedence over NavConfig' do
test 'UserConfiguration.categories should filter and order the navigation' 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'])

stub_user_configuration({
nav_categories: ['Files', 'Interactive Apps', 'Clusters']
Expand All @@ -213,8 +214,6 @@ def teardown
test 'should not create app menus if UserConfiguration.categories is empty' 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'])

stub_user_configuration({
nav_categories: []
Expand All @@ -225,12 +224,13 @@ 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'))
Expand All @@ -247,11 +247,11 @@ def teardown
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'))
OodAppkit.stubs(:clusters).returns(OodCore::Clusters.load_file('test/fixtures/config/clusters.d'))
NavConfig.stubs(:categories_whitelist?).returns(false)

get root_path

Expand Down

0 comments on commit d554aec

Please sign in to comment.