From 2e672c39a09577a0a16e75a10a249c923d8ee863 Mon Sep 17 00:00:00 2001 From: Vinnie Okada Date: Mon, 16 Mar 2015 13:59:50 -0600 Subject: 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. --- app/models/application_setting.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'app/models/application_setting.rb') diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 6abdf0c755a..1c87db613ae 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -27,9 +27,11 @@ class ApplicationSetting < ActiveRecord::Base if: :home_page_url_column_exist validates_each :restricted_visibility_levels do |record, attr, value| - value.each do |level| - unless Gitlab::VisibilityLevel.options.has_value?(level) - record.errors.add(attr, "'#{level}' is not a valid visibility level") + unless value.nil? + value.each do |level| + unless Gitlab::VisibilityLevel.options.has_value?(level) + record.errors.add(attr, "'#{level}' is not a valid visibility level") + end end end end -- cgit v1.2.3