Commit 7c511c2f authored by Grzegorz Bizon's avatar Grzegorz Bizon

Make it possible to set parent in CI config node

parent 2846f95d
......@@ -8,9 +8,9 @@ module Gitlab
class Entry
class InvalidError < StandardError; end
attr_reader :config
attr_accessor :description
attr_writer :key
attr_reader :config
attr_accessor :parent, :description
def initialize(config)
@config = config
......
......@@ -32,8 +32,9 @@ module Gitlab
end
node.new(value).tap do |entry|
entry.description = @attributes[:description]
entry.key = @attributes[:key]
entry.parent = @attributes[:parent]
entry.description = @attributes[:description]
end
end
end
......
......@@ -5,7 +5,7 @@ describe Gitlab::Ci::Config::Node::Factory do
let(:factory) { described_class.new(entry_class) }
let(:entry_class) { Gitlab::Ci::Config::Node::Script }
context 'when value setting value' do
context 'when setting up a value' do
it 'creates entry with valid value' do
entry = factory
.with(value: ['ls', 'pwd'])
......@@ -35,9 +35,21 @@ describe Gitlab::Ci::Config::Node::Factory do
expect(entry.key).to eq 'test key'
end
end
context 'when setting a parent' do
let(:parent) { Object.new }
it 'creates entry with valid parent' do
entry = factory
.with(value: 'ls', parent: parent)
.create!
expect(entry.parent).to eq parent
end
end
end
context 'when not setting value' do
context 'when not setting up a value' do
it 'raises error' do
expect { factory.create! }.to raise_error(
Gitlab::Ci::Config::Node::Factory::InvalidFactory
......
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