diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-15 21:09:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-15 21:09:05 +0300 |
commit | a0213db466c75403a5a79f95af8a0a5cff13014c (patch) | |
tree | 6118144407f99f1121c34e934cf0d96c991d578e /spec/services/ci/create_pipeline_service | |
parent | f5c3f32975addd56fe8659f1c346d0e56f0b23d9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/ci/create_pipeline_service')
-rw-r--r-- | spec/services/ci/create_pipeline_service/needs_spec.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/services/ci/create_pipeline_service/needs_spec.rb b/spec/services/ci/create_pipeline_service/needs_spec.rb index 512091035a2..a6b0a9662c9 100644 --- a/spec/services/ci/create_pipeline_service/needs_spec.rb +++ b/spec/services/ci/create_pipeline_service/needs_spec.rb @@ -238,5 +238,51 @@ RSpec.describe Ci::CreatePipelineService do .to eq('jobs:invalid_dag_job:needs config can not be an empty hash') end end + + context 'when the needed job has rules' do + let(:config) do + <<~YAML + build: + stage: build + script: exit 0 + rules: + - if: $CI_COMMIT_REF_NAME == "invalid" + + test: + stage: test + script: exit 0 + needs: [build] + YAML + end + + it 'returns error' do + expect(pipeline.yaml_errors) + .to eq("'test' job needs 'build' job, but it was not added to the pipeline") + end + + context 'when need is optional' do + let(:config) do + <<~YAML + build: + stage: build + script: exit 0 + rules: + - if: $CI_COMMIT_REF_NAME == "invalid" + + test: + stage: test + script: exit 0 + needs: + - job: build + optional: true + YAML + end + + it 'creates the pipeline without an error' do + expect(pipeline).to be_persisted + expect(pipeline.builds.pluck(:name)).to contain_exactly('test') + end + end + end end end |