diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-20 00:06:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-20 00:06:22 +0300 |
commit | 3d5ad15d2bf62ca70b1628afb64c5476e408781c (patch) | |
tree | 1f6906c1ee4b1b5652734e0a46d32b87ef9b27a0 /spec/services/ci/create_pipeline_service | |
parent | d2801eda8464e5e9ce730caf30111c1190fe87a0 (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/rules_spec.rb | 105 |
1 files changed, 30 insertions, 75 deletions
diff --git a/spec/services/ci/create_pipeline_service/rules_spec.rb b/spec/services/ci/create_pipeline_service/rules_spec.rb index c922266647b..2c93007f8e8 100644 --- a/spec/services/ci/create_pipeline_service/rules_spec.rb +++ b/spec/services/ci/create_pipeline_service/rules_spec.rb @@ -114,48 +114,36 @@ describe Ci::CreatePipelineService do end context 'matching the first rule in the list' do - it 'saves the pipeline' do - expect(pipeline).to be_persisted - end - - it 'sets the pipeline state to pending' do + it 'saves a pending pipeline' do expect(pipeline).to be_pending + expect(pipeline).to be_persisted end end context 'matching the last rule in the list' do let(:ref) { 'refs/heads/feature' } - it 'saves the pipeline' do - expect(pipeline).to be_persisted - end - - it 'sets the pipeline state to pending' do + it 'saves a pending pipeline' do expect(pipeline).to be_pending + expect(pipeline).to be_persisted end end context 'matching the when:never rule' do let(:ref) { 'refs/heads/wip' } - it 'does not save the pipeline' do - expect(pipeline).not_to be_persisted - end - - it 'attaches errors' do + it 'invalidates the pipeline with a workflow rules error' do expect(pipeline.errors[:base]).to include('Pipeline filtered out by workflow rules.') + expect(pipeline).not_to be_persisted end end context 'matching no rules in the list' do let(:ref) { 'refs/heads/fix' } - it 'does not save the pipeline' do - expect(pipeline).not_to be_persisted - end - - it 'attaches errors' do + it 'invalidates the pipeline with a workflow rules error' do expect(pipeline.errors[:base]).to include('Pipeline filtered out by workflow rules.') + expect(pipeline).not_to be_persisted end end end @@ -176,12 +164,9 @@ describe Ci::CreatePipelineService do end context 'matching the first rule in the list' do - it 'saves the pipeline' do - expect(pipeline).to be_persisted - end - - it 'sets the pipeline state to pending' do + it 'saves a pending pipeline' do expect(pipeline).to be_pending + expect(pipeline).to be_persisted end end end @@ -204,24 +189,18 @@ describe Ci::CreatePipelineService do context 'with partial match' do let(:ref) { 'refs/heads/feature' } - it 'saves the pipeline' do - expect(pipeline).to be_persisted - end - - it 'sets the pipeline state to pending' do + it 'saves a pending pipeline' do expect(pipeline).to be_pending + expect(pipeline).to be_persisted end end context 'with complete match' do let(:ref) { 'refs/heads/feature_conflict' } - it 'does not save the pipeline' do - expect(pipeline).not_to be_persisted - end - - it 'attaches errors' do + it 'invalidates the pipeline with a workflow rules error' do expect(pipeline.errors[:base]).to include('Pipeline filtered out by workflow rules.') + expect(pipeline).not_to be_persisted end end end @@ -245,12 +224,9 @@ describe Ci::CreatePipelineService do context 'where workflow passes and the job fails' do let(:ref) { 'refs/heads/master' } - it 'does not save the pipeline' do - expect(pipeline).not_to be_persisted - end - - it 'attaches an error about no job in the pipeline' do + it 'invalidates the pipeline with an empty jobs error' do expect(pipeline.errors[:base]).to include('No stages / jobs for this pipeline.') + expect(pipeline).not_to be_persisted end context 'with workflow:rules shut off' do @@ -258,12 +234,9 @@ describe Ci::CreatePipelineService do stub_feature_flags(workflow_rules: false) end - it 'does not save the pipeline' do - expect(pipeline).not_to be_persisted - end - - it 'attaches an error about no job in the pipeline' do + it 'invalidates the pipeline with an empty jobs error' do expect(pipeline.errors[:base]).to include('No stages / jobs for this pipeline.') + expect(pipeline).not_to be_persisted end end end @@ -271,12 +244,9 @@ describe Ci::CreatePipelineService do context 'where workflow passes and the job passes' do let(:ref) { 'refs/heads/feature' } - it 'saves the pipeline' do - expect(pipeline).to be_persisted - end - - it 'sets the pipeline state to pending' do + it 'saves a pending pipeline' do expect(pipeline).to be_pending + expect(pipeline).to be_persisted end context 'with workflow:rules shut off' do @@ -284,12 +254,9 @@ describe Ci::CreatePipelineService do stub_feature_flags(workflow_rules: false) end - it 'saves the pipeline' do - expect(pipeline).to be_persisted - end - - it 'sets the pipeline state to pending' do + it 'saves a pending pipeline' do expect(pipeline).to be_pending + expect(pipeline).to be_persisted end end end @@ -297,12 +264,9 @@ describe Ci::CreatePipelineService do context 'where workflow fails and the job fails' do let(:ref) { 'refs/heads/fix' } - it 'does not save the pipeline' do - expect(pipeline).not_to be_persisted - end - - it 'attaches an error about workflow rules' do + it 'invalidates the pipeline with a workflow rules error' do expect(pipeline.errors[:base]).to include('Pipeline filtered out by workflow rules.') + expect(pipeline).not_to be_persisted end context 'with workflow:rules shut off' do @@ -310,12 +274,9 @@ describe Ci::CreatePipelineService do stub_feature_flags(workflow_rules: false) end - it 'does not save the pipeline' do - expect(pipeline).not_to be_persisted - end - - it 'attaches an error about job rules' do + it 'invalidates the pipeline with an empty jobs error' do expect(pipeline.errors[:base]).to include('No stages / jobs for this pipeline.') + expect(pipeline).not_to be_persisted end end end @@ -323,12 +284,9 @@ describe Ci::CreatePipelineService do context 'where workflow fails and the job passes' do let(:ref) { 'refs/heads/wip' } - it 'does not save the pipeline' do - expect(pipeline).not_to be_persisted - end - - it 'attaches an error about workflow rules' do + it 'invalidates the pipeline with a workflow rules error' do expect(pipeline.errors[:base]).to include('Pipeline filtered out by workflow rules.') + expect(pipeline).not_to be_persisted end context 'with workflow:rules shut off' do @@ -336,12 +294,9 @@ describe Ci::CreatePipelineService do stub_feature_flags(workflow_rules: false) end - it 'saves the pipeline' do - expect(pipeline).to be_persisted - end - - it 'sets the pipeline state to pending' do + it 'saves a pending pipeline' do expect(pipeline).to be_pending + expect(pipeline).to be_persisted end end end |