... @@ -114,48 +114,36 @@ describe Ci::CreatePipelineService do
... @@ -114,48 +114,36 @@ describe Ci::CreatePipelineService do
end
end
context 'matching the first rule in the list' do
context 'matching the first rule in the list' do
it 'saves the pipeline' do
it 'saves a pending pipeline' do
expect ( pipeline ). to be_persisted
end
it 'sets the pipeline state to pending' do
expect ( pipeline ). to be_pending
expect ( pipeline ). to be_pending
expect ( pipeline ). to be_persisted
end
end
end
end
context 'matching the last rule in the list' do
context 'matching the last rule in the list' do
let ( :ref ) { 'refs/heads/feature' }
let ( :ref ) { 'refs/heads/feature' }
it 'saves the pipeline' do
it 'saves a pending pipeline' do
expect ( pipeline ). to be_persisted
end
it 'sets the pipeline state to pending' do
expect ( pipeline ). to be_pending
expect ( pipeline ). to be_pending
expect ( pipeline ). to be_persisted
end
end
end
end
context 'matching the when:never rule' do
context 'matching the when:never rule' do
let ( :ref ) { 'refs/heads/wip' }
let ( :ref ) { 'refs/heads/wip' }
it 'does not save the pipeline' do
it 'invalidates the pipeline with a workflow rules error' do
expect ( pipeline ). not_to be_persisted
end
it 'attaches errors' do
expect ( pipeline . errors [ :base ]). to include ( 'Pipeline filtered out by workflow rules.' )
expect ( pipeline . errors [ :base ]). to include ( 'Pipeline filtered out by workflow rules.' )
expect ( pipeline ). not_to be_persisted
end
end
end
end
context 'matching no rules in the list' do
context 'matching no rules in the list' do
let ( :ref ) { 'refs/heads/fix' }
let ( :ref ) { 'refs/heads/fix' }
it 'does not save the pipeline' do
it 'invalidates the pipeline with a workflow rules error' do
expect ( pipeline ). not_to be_persisted
end
it 'attaches errors' do
expect ( pipeline . errors [ :base ]). to include ( 'Pipeline filtered out by workflow rules.' )
expect ( pipeline . errors [ :base ]). to include ( 'Pipeline filtered out by workflow rules.' )
expect ( pipeline ). not_to be_persisted
end
end
end
end
end
end
... @@ -176,12 +164,9 @@ describe Ci::CreatePipelineService do
... @@ -176,12 +164,9 @@ describe Ci::CreatePipelineService do
end
end
context 'matching the first rule in the list' do
context 'matching the first rule in the list' do
it 'saves the pipeline' do
it 'saves a pending pipeline' do
expect ( pipeline ). to be_persisted
end
it 'sets the pipeline state to pending' do
expect ( pipeline ). to be_pending
expect ( pipeline ). to be_pending
expect ( pipeline ). to be_persisted
end
end
end
end
end
end
... @@ -204,24 +189,18 @@ describe Ci::CreatePipelineService do
... @@ -204,24 +189,18 @@ describe Ci::CreatePipelineService do
context 'with partial match' do
context 'with partial match' do
let ( :ref ) { 'refs/heads/feature' }
let ( :ref ) { 'refs/heads/feature' }
it 'saves the pipeline' do
it 'saves a pending pipeline' do
expect ( pipeline ). to be_persisted
end
it 'sets the pipeline state to pending' do
expect ( pipeline ). to be_pending
expect ( pipeline ). to be_pending
expect ( pipeline ). to be_persisted
end
end
end
end
context 'with complete match' do
context 'with complete match' do
let ( :ref ) { 'refs/heads/feature_conflict' }
let ( :ref ) { 'refs/heads/feature_conflict' }
it 'does not save the pipeline' do
it 'invalidates the pipeline with a workflow rules error' do
expect ( pipeline ). not_to be_persisted
end
it 'attaches errors' do
expect ( pipeline . errors [ :base ]). to include ( 'Pipeline filtered out by workflow rules.' )
expect ( pipeline . errors [ :base ]). to include ( 'Pipeline filtered out by workflow rules.' )
expect ( pipeline ). not_to be_persisted
end
end
end
end
end
end
... @@ -245,12 +224,9 @@ describe Ci::CreatePipelineService do
... @@ -245,12 +224,9 @@ describe Ci::CreatePipelineService do
context 'where workflow passes and the job fails' do
context 'where workflow passes and the job fails' do
let ( :ref ) { 'refs/heads/master' }
let ( :ref ) { 'refs/heads/master' }
it 'does not save the pipeline' do
it 'invalidates the pipeline with an empty jobs error' do
expect ( pipeline ). not_to be_persisted
end
it 'attaches an error about no job in the pipeline' do
expect ( pipeline . errors [ :base ]). to include ( 'No stages / jobs for this pipeline.' )
expect ( pipeline . errors [ :base ]). to include ( 'No stages / jobs for this pipeline.' )
expect ( pipeline ). not_to be_persisted
end
end
context 'with workflow:rules shut off' do
context 'with workflow:rules shut off' do
... @@ -258,12 +234,9 @@ describe Ci::CreatePipelineService do
... @@ -258,12 +234,9 @@ describe Ci::CreatePipelineService do
stub_feature_flags ( workflow_rules: false )
stub_feature_flags ( workflow_rules: false )
end
end
it 'does not save the pipeline' do
it 'invalidates the pipeline with an empty jobs error' do
expect ( pipeline ). not_to be_persisted
end
it 'attaches an error about no job in the pipeline' do
expect ( pipeline . errors [ :base ]). to include ( 'No stages / jobs for this pipeline.' )
expect ( pipeline . errors [ :base ]). to include ( 'No stages / jobs for this pipeline.' )
expect ( pipeline ). not_to be_persisted
end
end
end
end
end
end
... @@ -271,12 +244,9 @@ describe Ci::CreatePipelineService do
... @@ -271,12 +244,9 @@ describe Ci::CreatePipelineService do
context 'where workflow passes and the job passes' do
context 'where workflow passes and the job passes' do
let ( :ref ) { 'refs/heads/feature' }
let ( :ref ) { 'refs/heads/feature' }
it 'saves the pipeline' do
it 'saves a pending pipeline' do
expect ( pipeline ). to be_persisted
end
it 'sets the pipeline state to pending' do
expect ( pipeline ). to be_pending
expect ( pipeline ). to be_pending
expect ( pipeline ). to be_persisted
end
end
context 'with workflow:rules shut off' do
context 'with workflow:rules shut off' do
... @@ -284,12 +254,9 @@ describe Ci::CreatePipelineService do
... @@ -284,12 +254,9 @@ describe Ci::CreatePipelineService do
stub_feature_flags ( workflow_rules: false )
stub_feature_flags ( workflow_rules: false )
end
end
it 'saves the pipeline' do
it 'saves a pending pipeline' do
expect ( pipeline ). to be_persisted
end
it 'sets the pipeline state to pending' do
expect ( pipeline ). to be_pending
expect ( pipeline ). to be_pending
expect ( pipeline ). to be_persisted
end
end
end
end
end
end
... @@ -297,12 +264,9 @@ describe Ci::CreatePipelineService do
... @@ -297,12 +264,9 @@ describe Ci::CreatePipelineService do
context 'where workflow fails and the job fails' do
context 'where workflow fails and the job fails' do
let ( :ref ) { 'refs/heads/fix' }
let ( :ref ) { 'refs/heads/fix' }
it 'does not save the pipeline' do
it 'invalidates the pipeline with a workflow rules error' do
expect ( pipeline ). not_to be_persisted
end
it 'attaches an error about workflow rules' do
expect ( pipeline . errors [ :base ]). to include ( 'Pipeline filtered out by workflow rules.' )
expect ( pipeline . errors [ :base ]). to include ( 'Pipeline filtered out by workflow rules.' )
expect ( pipeline ). not_to be_persisted
end
end
context 'with workflow:rules shut off' do
context 'with workflow:rules shut off' do
... @@ -310,12 +274,9 @@ describe Ci::CreatePipelineService do
... @@ -310,12 +274,9 @@ describe Ci::CreatePipelineService do
stub_feature_flags ( workflow_rules: false )
stub_feature_flags ( workflow_rules: false )
end
end
it 'does not save the pipeline' do
it 'invalidates the pipeline with an empty jobs error' do
expect ( pipeline ). not_to be_persisted
end
it 'attaches an error about job rules' do
expect ( pipeline . errors [ :base ]). to include ( 'No stages / jobs for this pipeline.' )
expect ( pipeline . errors [ :base ]). to include ( 'No stages / jobs for this pipeline.' )
expect ( pipeline ). not_to be_persisted
end
end
end
end
end
end
... @@ -323,12 +284,9 @@ describe Ci::CreatePipelineService do
... @@ -323,12 +284,9 @@ describe Ci::CreatePipelineService do
context 'where workflow fails and the job passes' do
context 'where workflow fails and the job passes' do
let ( :ref ) { 'refs/heads/wip' }
let ( :ref ) { 'refs/heads/wip' }
it 'does not save the pipeline' do
it 'invalidates the pipeline with a workflow rules error' do
expect ( pipeline ). not_to be_persisted
end
it 'attaches an error about workflow rules' do
expect ( pipeline . errors [ :base ]). to include ( 'Pipeline filtered out by workflow rules.' )
expect ( pipeline . errors [ :base ]). to include ( 'Pipeline filtered out by workflow rules.' )
expect ( pipeline ). not_to be_persisted
end
end
context 'with workflow:rules shut off' do
context 'with workflow:rules shut off' do
... @@ -336,12 +294,9 @@ describe Ci::CreatePipelineService do
... @@ -336,12 +294,9 @@ describe Ci::CreatePipelineService do
stub_feature_flags ( workflow_rules: false )
stub_feature_flags ( workflow_rules: false )
end
end
it 'saves the pipeline' do
it 'saves a pending pipeline' do
expect ( pipeline ). to be_persisted
end
it 'sets the pipeline state to pending' do
expect ( pipeline ). to be_pending
expect ( pipeline ). to be_pending
expect ( pipeline ). to be_persisted
end
end
end
end
end
end
...
...
... ...