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
This commit is contained in:
Stan Hu 2018-09-10 21:28:03 -07:00
parent 2f990e3408
commit 70799b05ab
1 changed files with 18 additions and 10 deletions

View File

@ -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