Commit e8f995ef authored by Grzegorz Bizon's avatar Grzegorz Bizon

Pass root Ci config entry to each subsequent entry

parent 69a3755c
......@@ -13,7 +13,7 @@ module Gitlab
end
@config = loader.load
@global = Node::Global.new(@config, self)
@global = Node::Global.new(@config)
@global.process!
end
......
......@@ -7,14 +7,14 @@ module Gitlab
attr_reader :value, :nodes, :parent
def initialize(value, config, parent = nil)
def initialize(value, root = nil, parent = nil)
@value = value
@config = config
@root = root
@parent = parent
@nodes, @errors = [], []
keys.each_key do |key|
instance_variable_set("@#{key}", Null.new(nil, config, self))
instance_variable_set("@#{key}", Null.new(nil, root, self))
end
end
......@@ -24,7 +24,7 @@ module Gitlab
keys.each do |key, entry_class|
next unless @value.has_key?(key)
entry = entry_class.new(@value[key], @config, self)
entry = entry_class.new(@value[key], @root, self)
instance_variable_set("@#{key}", entry)
@nodes.append(entry)
end
......@@ -42,7 +42,7 @@ module Gitlab
end
def leaf?
keys.none?
keys.none? # TODO || !@value.is_a?(Hash)
end
def keys
......
require 'spec_helper'
describe Gitlab::Ci::Config::Node::BeforeScript do
let(:entry) { described_class.new(value, config) }
let(:config) { double('config') }
let(:entry) { described_class.new(value, double)}
describe '#validate!' do
before { entry.validate! }
......
require 'spec_helper'
describe Gitlab::Ci::Config::Node::Global do
let(:global) { described_class.new(hash, config) }
let(:config) { double('Config') }
let(:global) { described_class.new(hash) }
describe '#keys' do
it 'can contain global config keys' do
......
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