Simplify code related to setting default config values

This commit is contained in:
Grzegorz Bizon 2019-01-15 11:23:32 +01:00
parent 7b712d3598
commit 3c5846cdaa
3 changed files with 6 additions and 4 deletions

View File

@ -65,7 +65,7 @@ module Gitlab
end
def value
default.to_h.deep_merge(@subject.value.to_h)
default.to_h.deep_merge(subject.value.to_h)
end
end
end

View File

@ -6,6 +6,8 @@ module Gitlab
class Simplifiable < SimpleDelegator
EntryStrategy = Struct.new(:name, :condition)
attr_reader :subject
def initialize(config, **metadata)
unless self.class.const_defined?(:UnknownStrategy)
raise ArgumentError, 'UndefinedStrategy not available!'

View File

@ -30,11 +30,11 @@ describe Gitlab::Config::Entry::Configurable do
end
describe 'configured entries' do
let(:another) { double('another', default: nil) }
let(:entry_class) { double('entry_class', default: nil) }
before do
entry.class_exec(another) do |another|
entry :object, another, description: 'test object'
entry.class_exec(entry_class) do |entry_class|
entry :object, entry_class, description: 'test object'
end
end