diff --git a/lib/gitlab/ci/config/node/entry.rb b/lib/gitlab/ci/config/node/entry.rb index e2afeb1b3cff4a6ee0a56ff0a7a1292e5a41d8c2..c07e7cf652ed9530089916e4e68c27b24d894526 100644 --- a/lib/gitlab/ci/config/node/entry.rb +++ b/lib/gitlab/ci/config/node/entry.rb @@ -16,10 +16,14 @@ module Gitlab keys.each_key do |key| instance_variable_set("@#{key}", Null.new(nil, root, self)) end + + unless leaf? || value.is_a?(Hash) + @errors << 'should be a configuration entry with hash value' + end end def process! - return if leaf? + return if leaf? || !valid? keys.each do |key, entry_class| next unless @value.has_key?(key) @@ -42,7 +46,7 @@ module Gitlab end def leaf? - keys.none? # TODO || !@value.is_a?(Hash) + 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 c920dd3584c0f046a1bd7c24d5b4d99b3e53160e..f277c457a3be33d06b2a2bd31c0fa2b51d9d3ffb 100644 --- a/spec/lib/gitlab/ci/config/node/global_spec.rb +++ b/spec/lib/gitlab/ci/config/node/global_spec.rb @@ -58,4 +58,16 @@ describe Gitlab::Ci::Config::Node::Global do end end end + + context 'when value is not a hash' do + let(:hash) { [] } + + before { global.process! } + + describe '#valid?' do + it 'is not valid' do + expect(global).not_to be_valid + end + end + end end