Commit c69643ac authored by Stan Hu's avatar Stan Hu

Merge branch 'rules-specs-consolidation' into 'master'

Consolidated expectations into fewer create_pipeline_service/rules specs

See merge request gitlab-org/gitlab!20293
parents 6774f618 693da4d7
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment