Skip to content

Commit

Permalink
Added default_profile setting to allow admins to select the default p…
Browse files Browse the repository at this point in the history
…rofile for users (#3200)
  • Loading branch information
abujeda authored Nov 21, 2023
1 parent 8ef722b commit c1ca8e4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apps/dashboard/app/models/user_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ def profile
request_hostname
elsif user_settings[:profile]
user_settings[:profile].to_sym
elsif Configuration.default_profile
Configuration.default_profile.to_sym
end
end

Expand Down
3 changes: 2 additions & 1 deletion apps/dashboard/config/configuration_singleton.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def string_configs
:bc_clean_old_dirs_days => '30',
:google_analytics_tag_id => nil,
:project_template_dir => "#{config_root}/projects",
:rclone_extra_config => nil
:rclone_extra_config => nil,
:default_profile => nil
}.freeze
end

Expand Down
3 changes: 2 additions & 1 deletion apps/dashboard/test/fixtures/config/ondemand.d/string.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ auto_groups_filter: 'string from file'
bc_clean_old_dirs_days: 'string from file'
google_analytics_tag_id: 'string from file'
project_template_dir: 'string from file'
rclone_extra_config: 'string from file'
rclone_extra_config: 'string from file'
default_profile: 'string from file'
11 changes: 10 additions & 1 deletion apps/dashboard/test/models/user_configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,16 @@ def teardown
assert_equal :user_settings_profile_value, target.profile
end

test "profile should return nil when when Configuration.host_based_profiles is false and user profile is nil" do
test "profile should return default_profile when when Configuration.host_based_profiles is false and user profile is nil" do
Configuration.stubs(:host_based_profiles).returns(false)
Configuration.stubs(:default_profile).returns('myprofile')
target = UserConfiguration.new
target.update_user_settings({profile: nil})

assert_equal :myprofile, target.profile
end

test "profile should return nil when when Configuration.host_based_profiles is false, user profile is nil, and default_profile not set" do
Configuration.stubs(:host_based_profiles).returns(false)
target = UserConfiguration.new
target.update_user_settings({profile: nil})
Expand Down

0 comments on commit c1ca8e4

Please sign in to comment.