From 70799b05abb3d1b57f5a994894a891ef1e414cfd Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Mon, 10 Sep 2018 21:28:03 -0700 Subject: Add additional stub methods for FakeApplicationSetting In a migration spec, a default ApplicationSetting object may fail to create due to an unknown attribute and fall back to FakeApplicationSetting. FakeApplicationSetting appears to be missing a number of methods that are needed (https://gitlab.com/gitlab-org/gitlab-ce/issues/47491). This commit adds the ones needed to make an EE spec pass. Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/7543 --- lib/gitlab/fake_application_settings.rb | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/gitlab/fake_application_settings.rb b/lib/gitlab/fake_application_settings.rb index 753160cc562..2c827265d8c 100644 --- a/lib/gitlab/fake_application_settings.rb +++ b/lib/gitlab/fake_application_settings.rb @@ -5,16 +5,6 @@ # column type without parsing db/schema.rb. module Gitlab class FakeApplicationSettings < OpenStruct - def initialize(options = {}) - super - - FakeApplicationSettings.define_predicate_methods(options) - end - - def pick_repository_storage - repository_storages.sample - end - # Mimic ActiveRecord predicate methods for boolean values def self.define_predicate_methods(options) options.each do |key, value| @@ -27,5 +17,23 @@ module Gitlab end end end + + def initialize(options = {}) + super + + FakeApplicationSettings.define_predicate_methods(options) + end + + def key_restriction_for(type) + 0 + end + + def allowed_key_types + ApplicationSetting::SUPPORTED_KEY_TYPES + end + + def pick_repository_storage + repository_storages.sample + end end end -- cgit v1.2.1