summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2018-06-01 14:53:00 +0900
committerShinya Maeda <shinya@gitlab.com>2018-06-01 14:53:00 +0900
commitf7f60ab54ab69fb4d0c3a43406a9809edab7d762 (patch)
treef2f4e58924b903c668b32845d4177ef5e9811235
parent4beeb60255f228dc45dbe8f675a3cc59c0ea7773 (diff)
downloadgitlab-ce-f7f60ab54ab69fb4d0c3a43406a9809edab7d762.tar.gz
Add spec for variables expressions with pipeline iid
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb45
1 files changed, 32 insertions, 13 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
index feed7728f5a..6b18c615430 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
@@ -156,22 +156,41 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
end
end
- context 'when using only/except build policies' do
- let(:config) do
- { rspec: { script: 'rspec', stage: 'test', only: ['master'] },
- prod: { script: 'cap prod', stage: 'deploy', only: ['tags'] } }
- end
+ context 'when variables policy is specified' do
+ context 'when using only/except build policies' do
+ let(:config) do
+ { rspec: { script: 'rspec', stage: 'test', only: ['master'] },
+ prod: { script: 'cap prod', stage: 'deploy', only: ['tags'] } }
+ end
- let(:pipeline) do
- build(:ci_pipeline, ref: 'master', config: config)
- end
+ let(:pipeline) do
+ build(:ci_pipeline, ref: 'master', config: config)
+ end
- it 'populates pipeline according to used policies' do
- step.perform!
+ it 'populates pipeline according to used policies' do
+ step.perform!
- expect(pipeline.stages.size).to eq 1
- expect(pipeline.stages.first.builds.size).to eq 1
- expect(pipeline.stages.first.builds.first.name).to eq 'rspec'
+ expect(pipeline.stages.size).to eq 1
+ expect(pipeline.stages.first.builds.size).to eq 1
+ expect(pipeline.stages.first.builds.first.name).to eq 'rspec'
+ end
+
+ context 'when variables expression is specified' do
+ let(:config) do
+ { rspec: { script: 'rspec', only: { variables: ["$CI_PIPELINE_IID == '1'"] } },
+ prod: { script: 'cap prod', only: { variables: ["$CI_PIPELINE_IID == '1000'"] } } }
+ end
+
+ context 'when pipeline iid is the subject' do
+ it 'populates pipeline according to used policies' do
+ step.perform!
+
+ expect(pipeline.stages.size).to eq 1
+ expect(pipeline.stages.first.builds.size).to eq 1
+ expect(pipeline.stages.first.builds.first.name).to eq 'rspec'
+ end
+ end
+ end
end
end
end