diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 18:18:33 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-16 18:18:33 +0000 |
commit | f64a639bcfa1fc2bc89ca7db268f594306edfd7c (patch) | |
tree | a2c3c2ebcc3b45e596949db485d6ed18ffaacfa1 /spec/services/ci/create_pipeline_service/needs_spec.rb | |
parent | bfbc3e0d6583ea1a91f627528bedc3d65ba4b10f (diff) | |
download | gitlab-ce-f64a639bcfa1fc2bc89ca7db268f594306edfd7c.tar.gz |
Add latest changes from gitlab-org/gitlab@13-10-stable-eev13.10.0-rc40
Diffstat (limited to 'spec/services/ci/create_pipeline_service/needs_spec.rb')
-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 |