Commit 5b84708d authored by Sean McGivern's avatar Sean McGivern

Merge branch 'tc-cleanup-application-settings-spec' into 'master'

Cleanup application settings spec

See merge request !10189
parents c7403521 5058fc67
...@@ -45,15 +45,6 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController ...@@ -45,15 +45,6 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end end
def application_setting_params 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] import_sources = params[:application_setting][:import_sources]
if import_sources.nil? if import_sources.nil?
params[:application_setting][:import_sources] = [] params[:application_setting][:import_sources] = []
......
...@@ -6,23 +6,34 @@ describe Admin::ApplicationSettingsController do ...@@ -6,23 +6,34 @@ describe Admin::ApplicationSettingsController do
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
before do before do
sign_in(admin)
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
end end
describe 'PATCH #update' do describe 'PUT #update' do
before do
sign_in(admin)
end
it 'updates the default_project_visibility for string value' do it 'updates the default_project_visibility for string value' do
patch :update, application_setting: { default_project_visibility: "20" } 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)
end
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(response).to redirect_to(admin_application_settings_path)
expect(ApplicationSetting.current.default_project_visibility).to eq Gitlab::VisibilityLevel::PUBLIC expect(ApplicationSetting.current.restricted_visibility_levels).to eq([10, 20])
end end
it 'falls back to default with default_project_visibility setting is omitted' do it 'falls back to defaults when settings are omitted' do
patch :update, application_setting: {} put :update, application_setting: {}
expect(response).to redirect_to(admin_application_settings_path) 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 end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment