diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-06 15:08:05 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-06 15:08:05 +0000 |
commit | f78257cbddd711e18cbce93ad740a4aa0acac347 (patch) | |
tree | 7f018abe3ce1c0010879cc480f348a35e616fabb /spec/lib/gitlab/ci/yaml_processor_spec.rb | |
parent | f500600a43b531e2e7a5858b74bd35312b02c349 (diff) | |
download | gitlab-ce-f78257cbddd711e18cbce93ad740a4aa0acac347.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/ci/yaml_processor_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/yaml_processor_spec.rb | 76 |
1 files changed, 54 insertions, 22 deletions
diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index e303557bd00..5c85a136972 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -509,28 +509,44 @@ module Gitlab describe "before_script" do context "in global context" do - let(:config) do - { - before_script: ["global script"], - test: { script: ["script"] } - } + using RSpec::Parameterized::TableSyntax + + where(:inherit, :result) do + nil | ["global script"] + { default: false } | nil + { default: true } | ["global script"] end - it "return commands with scripts concatenated" do - expect(subject[:options][:before_script]).to eq(["global script"]) + with_them do + let(:config) do + { + before_script: ["global script"], + test: { script: ["script"], inherit: inherit } + } + end + + it { expect(subject[:options][:before_script]).to eq(result) } end end context "in default context" do - let(:config) do - { - default: { before_script: ["global script"] }, - test: { script: ["script"] } - } + using RSpec::Parameterized::TableSyntax + + where(:inherit, :result) do + nil | ["global script"] + { default: false } | nil + { default: true } | ["global script"] end - it "return commands with scripts concatenated" do - expect(subject[:options][:before_script]).to eq(["global script"]) + with_them do + let(:config) do + { + default: { before_script: ["global script"] }, + test: { script: ["script"], inherit: inherit } + } + end + + it { expect(subject[:options][:before_script]).to eq(result) } end end @@ -793,7 +809,7 @@ module Gitlab context 'when job and global variables are defined' do let(:global_variables) do - { 'VAR1' => 'global1', 'VAR3' => 'global3' } + { 'VAR1' => 'global1', 'VAR3' => 'global3', 'VAR4' => 'global4' } end let(:job_variables) do { 'VAR1' => 'value1', 'VAR2' => 'value2' } @@ -802,16 +818,32 @@ module Gitlab { before_script: ['pwd'], variables: global_variables, - rspec: { script: 'rspec', variables: job_variables } + rspec: { script: 'rspec', variables: job_variables, inherit: inherit } } end - it 'returns all unique variables' do - expect(subject).to contain_exactly( - { key: 'VAR3', value: 'global3', public: true }, - { key: 'VAR1', value: 'value1', public: true }, - { key: 'VAR2', value: 'value2', public: true } - ) + context 'when no inheritance is specified' do + let(:inherit) { } + + it 'returns all unique variables' do + expect(subject).to contain_exactly( + { key: 'VAR4', value: 'global4', public: true }, + { key: 'VAR3', value: 'global3', public: true }, + { key: 'VAR1', value: 'value1', public: true }, + { key: 'VAR2', value: 'value2', public: true } + ) + end + end + + context 'when inheritance is disabled' do + let(:inherit) { { variables: false } } + + it 'does not inherit variables' do + expect(subject).to contain_exactly( + { key: 'VAR1', value: 'value1', public: true }, + { key: 'VAR2', value: 'value2', public: true } + ) + end end end |