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