From 71672dfa6afbb374b24ae5457a58204708d948ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Wed, 12 Dec 2018 12:59:06 +0100 Subject: Return an ApplicationSetting in CurrentSettings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This replaces the use of fake_application_settings with `::ApplicationSetting.build`_from_defaults. The reason is that `fake_application_settings` doesn't have the custom accessors that `ApplicationSetting` has, e.g. `#commit_email_hostname`, thus this can lead to unexpected `nil` values which comes from the database column instead of `.default_commit_email_hostname` returned by `ApplicationSetting#commit_email_hostname`. Using `::ApplicationSetting.build_from_defaults` should be safe as it doesn't try to `INSERT` a DB record, in contrary to `::ApplicationSetting.create_from_defaults` which we used to use, and which created issues that the introduction of `fake_application_settings` tried to resolve (575dced5). Signed-off-by: Rémy Coutable --- app/models/application_setting.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models/application_setting.rb') diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 4319db42019..54139f61a16 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -382,7 +382,7 @@ class ApplicationSetting < ActiveRecord::Base end def restricted_visibility_levels=(levels) - super(levels.map { |level| Gitlab::VisibilityLevel.level_value(level) }) + super(levels&.map { |level| Gitlab::VisibilityLevel.level_value(level) }) end def strip_sentry_values -- cgit v1.2.3