Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport #3200 to 3.0 #3213

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/dashboard/app/models/user_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ def profile

if Configuration.host_based_profiles
request_hostname
elsif CurrentUser.user_settings[:profile]
CurrentUser.user_settings[:profile].to_sym
elsif user_settings[:profile]
user_settings[:profile].to_sym
elsif Configuration.default_profile
Configuration.default_profile.to_sym
end
end

Expand Down
13 changes: 7 additions & 6 deletions apps/dashboard/config/configuration_singleton.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ def boolean_configs
# @return [Hash] key/value pairs of defaults
def string_configs
{
:module_file_dir => nil,
:user_settings_file => '.ood',
:facl_domain => nil,
:auto_groups_filter => nil,
:bc_clean_old_dirs_days => '30',
:project_template_dir => "#{config_root}/projects"
:module_file_dir => nil,
:user_settings_file => '.ood',
:facl_domain => nil,
:auto_groups_filter => nil,
:bc_clean_old_dirs_days => '30',
:project_template_dir => "#{config_root}/projects",
:default_profile => nil
}.freeze
end

Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/test/fixtures/config/ondemand.d/string.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ facl_domain: 'string from file'
auto_groups_filter: 'string from file'
bc_clean_old_dirs_days: 'string from file'
project_template_dir: '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 @@ -204,7 +204,16 @@ class UserConfigurationTest < ActiveSupport::TestCase
assert_equal :user_settings_profile_value, target.profile
end

test "profile should return nil when when Configuration.host_based_profiles is false and CurrentUser 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)
CurrentUser.stubs(:user_settings).returns({})
target = UserConfiguration.new
Expand Down