diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-04-11 13:09:46 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-04-18 13:17:47 +0200 |
commit | b578fbfb8572860490cdfd0163bfbf5f999bb1e6 (patch) | |
tree | 0cab0da4537210bb8381be968c663439f5baf96a /spec | |
parent | a1363d39c6fe79d830dbce468c02880d2a5d7996 (diff) | |
download | gitlab-ce-b578fbfb8572860490cdfd0163bfbf5f999bb1e6.tar.gz |
Make it possible to override build variables
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/build_spec.rb | 24 |
2 files changed, 20 insertions, 6 deletions
diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index a3a0d06e149..c2908f855e3 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -364,7 +364,7 @@ module Ci end context 'when job variables are defined' do - let(:job_variables) { { KEY1: 'value1', SOME_KEY_2: 'value2'} } + let(:job_variables) { { KEY1: 'value1', SOME_KEY_2: 'value2' } } let(:yaml_config) do YAML.dump( { before_script: ['pwd'], diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb index ee44a4c5f12..94d51435f37 100644 --- a/spec/models/build_spec.rb +++ b/spec/models/build_spec.rb @@ -240,17 +240,31 @@ describe Ci::Build, models: true do end context 'when job variables are defined' do + def result_variables + job_variables.map do |key, value| + { key: key, value: value, public: true } + end + end + before { build.update_attribute(:options, variables: job_variables) } context 'when job variables are unique' do let(:job_variables) { { KEY1: 'value1', KEY2: 'value2' } } - let(:resulting_variables) do - [{ key: :KEY1, value: 'value1', public: true }, - { key: :KEY2, value: 'value2', public: true }] - end it 'includes job variables' do - expect(subject).to include(*resulting_variables) + expect(subject).to include(*result_variables) + end + end + + context 'when job variable has same key other variable has' do + let(:job_variables) { { CI_BUILD_NAME: 'overridden' } } + + it 'contains job yaml variable' do + expect(subject).to include(*result_variables) + end + + it 'contains only one variable with this key' do + expect(subject.count { |var| var[:key] == :CI_BUILD_NAME } ).to eq 1 end end end |