Skip to content

Commit 3c5846c

Browse files
committed
Simplify code related to setting default config values
1 parent 7b712d3 commit 3c5846c

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lib/gitlab/ci/config/entry/policy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def errors
6565
end
6666

6767
def value
68-
default.to_h.deep_merge(@subject.value.to_h)
68+
default.to_h.deep_merge(subject.value.to_h)
6969
end
7070
end
7171
end

lib/gitlab/config/entry/simplifiable.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ module Entry
66
class Simplifiable < SimpleDelegator
77
EntryStrategy = Struct.new(:name, :condition)
88

9+
attr_reader :subject
10+
911
def initialize(config, **metadata)
1012
unless self.class.const_defined?(:UnknownStrategy)
1113
raise ArgumentError, 'UndefinedStrategy not available!'

spec/lib/gitlab/config/entry/configurable_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
end
3131

3232
describe 'configured entries' do
33-
let(:another) { double('another', default: nil) }
33+
let(:entry_class) { double('entry_class', default: nil) }
3434

3535
before do
36-
entry.class_exec(another) do |another|
37-
entry :object, another, description: 'test object'
36+
entry.class_exec(entry_class) do |entry_class|
37+
entry :object, entry_class, description: 'test object'
3838
end
3939
end
4040

0 commit comments

Comments
 (0)