Remove redundant code to convert restricted_levels to integers
The ApplicationSetting#restricted_visibility_levels= now takes care of converting string formatted levels to integers.
This commit is contained in:
parent
7bfa523485
commit
5058fc67ac
|
@ -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] = []
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue