diff options
author | Toon Claes <toon@gitlab.com> | 2017-03-23 15:25:42 +0100 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2017-03-23 15:25:42 +0100 |
commit | 5058fc67acdde120e673c24555908394c72a343b (patch) | |
tree | 444db01345d9b40e3d3d8c02bd6b4da508a92393 | |
parent | 7bfa5234855e8de996d5c7dff14ad6c19ea9d33b (diff) | |
download | gitlab-ce-5058fc67acdde120e673c24555908394c72a343b.tar.gz |
Remove redundant code to convert restricted_levels to integers
The ApplicationSetting#restricted_visibility_levels= now takes care of
converting string formatted levels to integers.
-rw-r--r-- | app/controllers/admin/application_settings_controller.rb | 9 | ||||
-rw-r--r-- | spec/controllers/admin/application_settings_controller_spec.rb | 14 |
2 files changed, 11 insertions, 12 deletions
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index 8d831ffdd70..0bfbe47eb4f 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -45,15 +45,6 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController end def application_setting_params - restricted_levels = params[:application_setting][:restricted_visibility_levels] - if restricted_levels.nil? - params[:application_setting][:restricted_visibility_levels] = [] - else - restricted_levels.map! do |level| - level.to_i - end - end - import_sources = params[:application_setting][:import_sources] if import_sources.nil? params[:application_setting][:import_sources] = [] diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb index 19b35a346b7..5dd8f66343f 100644 --- a/spec/controllers/admin/application_settings_controller_spec.rb +++ b/spec/controllers/admin/application_settings_controller_spec.rb @@ -18,14 +18,22 @@ describe Admin::ApplicationSettingsController do put :update, application_setting: { default_project_visibility: "20" } expect(response).to redirect_to(admin_application_settings_path) - expect(ApplicationSetting.current.default_project_visibility).to eq Gitlab::VisibilityLevel::PUBLIC + expect(ApplicationSetting.current.default_project_visibility).to eq(Gitlab::VisibilityLevel::PUBLIC) end - it 'falls back to default with default_project_visibility setting is omitted' do + it 'update the restricted levels for string values' do + put :update, application_setting: { restricted_visibility_levels: %w[10 20] } + + expect(response).to redirect_to(admin_application_settings_path) + expect(ApplicationSetting.current.restricted_visibility_levels).to eq([10, 20]) + end + + it 'falls back to defaults when settings are omitted' do put :update, application_setting: {} expect(response).to redirect_to(admin_application_settings_path) - expect(ApplicationSetting.current.default_project_visibility).to eq Gitlab::VisibilityLevel::PRIVATE + expect(ApplicationSetting.current.default_project_visibility).to eq(Gitlab::VisibilityLevel::PRIVATE) + expect(ApplicationSetting.current.restricted_visibility_levels).to be_empty end end end |