summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-03-20 22:54:34 +0100
committerToon Claes <toon@gitlab.com>2017-03-20 22:57:45 +0100
commit4e1cebabc7906f46cfab15602a5b9ae15448598d (patch)
tree274fc0aaff418edd5c2b1f064da8417646a5c5a4
parent71306f14f69b9798a21905cfa8160c4990ca5d5d (diff)
downloadgitlab-ce-4e1cebabc7906f46cfab15602a5b9ae15448598d.tar.gz
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.
-rw-r--r--app/controllers/admin/application_settings_controller.rb12
-rw-r--r--spec/controllers/admin/application_settings_controller_spec.rb28
2 files changed, 28 insertions, 12 deletions
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb
index 11f69c14a5d..8d831ffdd70 100644
--- a/app/controllers/admin/application_settings_controller.rb
+++ b/app/controllers/admin/application_settings_controller.rb
@@ -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] = []
diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb
new file mode 100644
index 00000000000..84a1ce773a1
--- /dev/null
+++ b/spec/controllers/admin/application_settings_controller_spec.rb
@@ -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