Commit 6bd67f52 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Do not process new Ci config entry when invalid

parent e8f995ef
...@@ -16,10 +16,14 @@ module Gitlab ...@@ -16,10 +16,14 @@ module Gitlab
keys.each_key do |key| keys.each_key do |key|
instance_variable_set("@#{key}", Null.new(nil, root, self)) instance_variable_set("@#{key}", Null.new(nil, root, self))
end end
unless leaf? || value.is_a?(Hash)
@errors << 'should be a configuration entry with hash value'
end
end end
def process! def process!
return if leaf? return if leaf? || !valid?
keys.each do |key, entry_class| keys.each do |key, entry_class|
next unless @value.has_key?(key) next unless @value.has_key?(key)
...@@ -42,7 +46,7 @@ module Gitlab ...@@ -42,7 +46,7 @@ module Gitlab
end end
def leaf? def leaf?
keys.none? # TODO || !@value.is_a?(Hash) keys.none?
end end
def keys def keys
......
...@@ -58,4 +58,16 @@ describe Gitlab::Ci::Config::Node::Global do ...@@ -58,4 +58,16 @@ describe Gitlab::Ci::Config::Node::Global do
end end
end 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 end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment