From b95c60a0715b5639e70b64e04fd4923e8bdd1923 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon <grzesiek.bizon@gmail.com> Date: Tue, 7 Jun 2016 11:26:39 +0200 Subject: [PATCH] Do not process Ci config node when node is a leaf --- lib/gitlab/ci/config/node/entry.rb | 10 ++++++++-- spec/lib/gitlab/ci/config/node/global_spec.rb | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/gitlab/ci/config/node/entry.rb b/lib/gitlab/ci/config/node/entry.rb index e8ed5f54c5b..007585d4019 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 4b464db35be..06c88b61f0c 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 -- GitLab