Commit 4e1cebab authored by Toon Claes's avatar Toon Claes

Undo explicit conversion to Integer

With the changes in Gitlab::VisibilityLevel it is no longer needed to
explicit conversion to Integer in the controller itself.
parent 71306f14
...@@ -45,18 +45,6 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController ...@@ -45,18 +45,6 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end end
def application_setting_params def application_setting_params
default_visibilities = [:default_project_visibility, :default_snippet_visibility, :default_group_visibility]
default_visibilities.each do |visibility|
value = params[:application_setting][visibility]
params[:application_setting][visibility] =
if value.present?
value.to_i
else
Gitlab::VisibilityLevel::PRIVATE
end
end
restricted_levels = params[:application_setting][:restricted_visibility_levels] restricted_levels = params[:application_setting][:restricted_visibility_levels]
if restricted_levels.nil? if restricted_levels.nil?
params[:application_setting][:restricted_visibility_levels] = [] params[:application_setting][:restricted_visibility_levels] = []
......
require 'spec_helper'
describe Admin::ApplicationSettingsController do
include StubENV
let(:admin) { create(:admin) }
before do
sign_in(admin)
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
end
describe 'PATCH #update' do
it 'updates the default_project_visibility for string value' do
patch :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 'falls back to default with default_project_visibility setting is omitted' do
patch :update, application_setting: {}
expect(response).to redirect_to(admin_application_settings_path)
expect(ApplicationSetting.current.default_project_visibility).to eq Gitlab::VisibilityLevel::PRIVATE
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