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.
This commit is contained in:
Toon Claes 2017-03-20 22:54:34 +01:00
parent 71306f14f6
commit 4e1cebabc7
2 changed files with 28 additions and 12 deletions

View File

@ -45,18 +45,6 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end
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]
if restricted_levels.nil?
params[:application_setting][:restricted_visibility_levels] = []

View File

@ -0,0 +1,28 @@
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