diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-01-15 11:23:32 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-01-15 11:23:32 +0100 |
commit | 3c5846cdaae8784ca8c91308c42a7d4f5b91ac0a (patch) | |
tree | c1ee0973d076db8a84723c19b9a8dbdf52e1064a | |
parent | 7b712d359880cb15bad4c0f01308bf12b1518e60 (diff) | |
download | gitlab-ce-3c5846cdaae8784ca8c91308c42a7d4f5b91ac0a.tar.gz |
Simplify code related to setting default config values
-rw-r--r-- | lib/gitlab/ci/config/entry/policy.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/config/entry/simplifiable.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/config/entry/configurable_spec.rb | 6 |
3 files changed, 6 insertions, 4 deletions
diff --git a/lib/gitlab/ci/config/entry/policy.rb b/lib/gitlab/ci/config/entry/policy.rb index 5195c4d87fe..9c677bf6617 100644 --- a/lib/gitlab/ci/config/entry/policy.rb +++ b/lib/gitlab/ci/config/entry/policy.rb @@ -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 diff --git a/lib/gitlab/config/entry/simplifiable.rb b/lib/gitlab/config/entry/simplifiable.rb index 22a0b448230..5fbf7565e2a 100644 --- a/lib/gitlab/config/entry/simplifiable.rb +++ b/lib/gitlab/config/entry/simplifiable.rb @@ -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!' diff --git a/spec/lib/gitlab/config/entry/configurable_spec.rb b/spec/lib/gitlab/config/entry/configurable_spec.rb index 09aa7f91b83..37e38e49c0d 100644 --- a/spec/lib/gitlab/config/entry/configurable_spec.rb +++ b/spec/lib/gitlab/config/entry/configurable_spec.rb @@ -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 |