diff options
author | Kamil TrzciĆski <ayufan@ayufan.eu> | 2019-06-18 13:36:07 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-06-18 13:36:07 +0300 |
commit | 505d71ec88e04f649251b3848a094a9e5ab0f8d5 (patch) | |
tree | 9e823a5fa17771ec01b3e0cb33b6283d217dd12e /spec/lib/gitlab/config | |
parent | c167cc58d3efe2bf1d8f9ccb1a58d7819fef1901 (diff) |
Introduce default: for gitlab-ci.yml
This moves all existing `image/services/before_script/variables`
into `default:`. This allows us to easily add a default and
top-level entries. `default`: is keep backward compatible: to
be considered to be job if `default:script:` is specified. This
behavior should be removed.
All existing `image/services/before_script/variables` are properly
handled in root context.
Diffstat (limited to 'spec/lib/gitlab/config')
-rw-r--r-- | spec/lib/gitlab/config/entry/configurable_spec.rb | 27 | ||||
-rw-r--r-- | spec/lib/gitlab/config/entry/factory_spec.rb | 25 |
2 files changed, 45 insertions, 7 deletions
diff --git a/spec/lib/gitlab/config/entry/configurable_spec.rb b/spec/lib/gitlab/config/entry/configurable_spec.rb index 37e38e49c0d..62dbf20ddf8 100644 --- a/spec/lib/gitlab/config/entry/configurable_spec.rb +++ b/spec/lib/gitlab/config/entry/configurable_spec.rb @@ -34,18 +34,25 @@ describe Gitlab::Config::Entry::Configurable do before do entry.class_exec(entry_class) do |entry_class| - entry :object, entry_class, description: 'test object' + entry :object, entry_class, + description: 'test object', + inherit: true, + reserved: true end end describe '.nodes' do it 'has valid nodes' do - expect(entry.nodes).to include :object + expect(entry.nodes).to include(:object) end it 'creates a node factory' do - expect(entry.nodes[:object]) - .to be_an_instance_of Gitlab::Config::Entry::Factory + factory = entry.nodes[:object] + + expect(factory).to be_an_instance_of(Gitlab::Config::Entry::Factory) + expect(factory.description).to eq('test object') + expect(factory.inheritable?).to eq(true) + expect(factory.reserved?).to eq(true) end it 'returns a duplicated factory object' do @@ -55,5 +62,17 @@ describe Gitlab::Config::Entry::Configurable do expect(first_factory).not_to be_equal(second_factory) end end + + describe '.reserved_node_names' do + before do + entry.class_exec(entry_class) do |entry_class| + entry :not_reserved, entry_class + end + end + + it 'returns all nodes with reserved: true' do + expect(entry.reserved_node_names).to contain_exactly(:object) + end + end end end diff --git a/spec/lib/gitlab/config/entry/factory_spec.rb b/spec/lib/gitlab/config/entry/factory_spec.rb index c29d17eaee3..42f8be8e141 100644 --- a/spec/lib/gitlab/config/entry/factory_spec.rb +++ b/spec/lib/gitlab/config/entry/factory_spec.rb @@ -23,17 +23,36 @@ describe Gitlab::Config::Entry::Factory do end context 'when setting description' do - it 'creates entry with description' do - entry = factory + before do + factory .value(%w(ls pwd)) .with(description: 'test description') - .create! + end + + it 'configures description' do + expect(factory.description).to eq 'test description' + end + + it 'creates entry with description' do + entry = factory.create! expect(entry.value).to eq %w(ls pwd) expect(entry.description).to eq 'test description' end end + context 'when setting inherit' do + before do + factory + .value(%w(ls pwd)) + .with(inherit: true) + end + + it 'makes object inheritable' do + expect(factory.inheritable?).to eq true + end + end + context 'when setting key' do it 'creates entry with custom key' do entry = factory |