Commit 2e672c39 authored by Vinnie Okada's avatar Vinnie Okada

Fix restricted visibility bugs

Check for nil values in the restricted_visibility_level validation
method, and set the restricted visibility request parameter to `[]` when
it's missing from the request.
parent 7c3c836d
...@@ -21,7 +21,9 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController ...@@ -21,7 +21,9 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
def application_setting_params def application_setting_params
restricted_levels = params[:application_setting][:restricted_visibility_levels] restricted_levels = params[:application_setting][:restricted_visibility_levels]
unless restricted_levels.nil? if restricted_levels.nil?
params[:application_setting][:restricted_visibility_levels] = []
else
restricted_levels.map! do |level| restricted_levels.map! do |level|
level.to_i level.to_i
end end
......
...@@ -27,9 +27,11 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -27,9 +27,11 @@ class ApplicationSetting < ActiveRecord::Base
if: :home_page_url_column_exist if: :home_page_url_column_exist
validates_each :restricted_visibility_levels do |record, attr, value| validates_each :restricted_visibility_levels do |record, attr, value|
value.each do |level| unless value.nil?
unless Gitlab::VisibilityLevel.options.has_value?(level) value.each do |level|
record.errors.add(attr, "'#{level}' is not a valid visibility level") unless Gitlab::VisibilityLevel.options.has_value?(level)
record.errors.add(attr, "'#{level}' is not a valid visibility level")
end
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