diff --git a/lib/gitlab/ci/config/node/entry.rb b/lib/gitlab/ci/config/node/entry.rb index e8ed5f54c5b2b68e042fbd6b9087162b7d1caa1a..007585d4019b79cd80cd8dfed5701f4ff27fc84b 100644 --- a/lib/gitlab/ci/config/node/entry.rb +++ b/lib/gitlab/ci/config/node/entry.rb @@ -16,6 +16,8 @@ module Gitlab end def process! + return if leaf? + keys.each_pair do |key, entry| next unless @value.include?(key) @nodes[key] = entry.new(@value[key], @config, self) @@ -29,12 +31,16 @@ module Gitlab @errors + nodes.map(&:errors).flatten end + def nodes + @nodes.values + end + def valid? errors.none? end - def nodes - @nodes.values + def leaf? + keys.none? end def keys diff --git a/spec/lib/gitlab/ci/config/node/global_spec.rb b/spec/lib/gitlab/ci/config/node/global_spec.rb index 4b464db35be6f502ba8d5d049f5a575391df0b70..06c88b61f0c936b56eb8f21c0abb5f9e8ad567ed 100644 --- a/spec/lib/gitlab/ci/config/node/global_spec.rb +++ b/spec/lib/gitlab/ci/config/node/global_spec.rb @@ -31,6 +31,12 @@ describe Gitlab::Ci::Config::Node::Global do .to be_an_instance_of Gitlab::Ci::Config::Node::BeforeScript end end + + describe '#leaf?' do + it 'is not leaf' do + expect(global).not_to be_leaf + end + end end context 'when hash is not valid' do