diff options
Diffstat (limited to 'spec/services/ci/create_pipeline_service_spec.rb')
-rw-r--r-- | spec/services/ci/create_pipeline_service_spec.rb | 73 |
1 files changed, 30 insertions, 43 deletions
diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index f9015752644..e1f1bdc41a1 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -91,6 +91,23 @@ RSpec.describe Ci::CreatePipelineService do .with({ source: 'push' }, 5) end + it 'tracks included template usage' do + expect_next_instance_of(Gitlab::Ci::Pipeline::Chain::TemplateUsage) do |instance| + expect(instance).to receive(:perform!) + end + + execute_service + end + + describe 'recording a conversion event' do + it 'schedules a record conversion event worker' do + expect(Experiments::RecordConversionEventWorker).to receive(:perform_async).with(:ci_syntax_templates, user.id) + expect(Experiments::RecordConversionEventWorker).to receive(:perform_async).with(:pipelines_empty_state, user.id) + + pipeline + end + end + context 'when merge requests already exist for this source branch' do let(:merge_request_1) do create(:merge_request, source_branch: 'feature', target_branch: "master", source_project: project) @@ -481,6 +498,7 @@ RSpec.describe Ci::CreatePipelineService do expect(execute_service).not_to be_persisted expect(Ci::Pipeline.count).to eq(0) + expect(Namespaces::OnboardingPipelineCreatedWorker).not_to receive(:perform_async) end shared_examples 'a failed pipeline' do @@ -1418,6 +1436,13 @@ RSpec.describe Ci::CreatePipelineService do pipeline end + it 'schedules a namespace onboarding create action worker' do + expect(Namespaces::OnboardingPipelineCreatedWorker) + .to receive(:perform_async).with(project.namespace_id) + + pipeline + end + context 'when target sha is specified' do let(:target_sha) { merge_request.target_branch_sha } @@ -1688,9 +1713,11 @@ RSpec.describe Ci::CreatePipelineService do shared_examples 'has errors' do it 'contains the expected errors' do expect(pipeline.builds).to be_empty - expect(pipeline.yaml_errors).to eq("test_a: needs 'build_a'") - expect(pipeline.error_messages.map(&:content)).to contain_exactly("test_a: needs 'build_a'") - expect(pipeline.errors[:base]).to contain_exactly("test_a: needs 'build_a'") + + error_message = "'test_a' job needs 'build_a' job, but it was not added to the pipeline" + expect(pipeline.yaml_errors).to eq(error_message) + expect(pipeline.error_messages.map(&:content)).to contain_exactly(error_message) + expect(pipeline.errors[:base]).to contain_exactly(error_message) end end @@ -2385,16 +2412,6 @@ RSpec.describe Ci::CreatePipelineService do expect(build_names).to contain_exactly('regular-job') end - context 'when FF ci_seed_block_run_before_workflow_rules is disabled' do - before do - stub_feature_flags(ci_seed_block_run_before_workflow_rules: false) - end - - it 'does not a pipeline' do - expect(pipeline).not_to be_persisted - end - end - context 'when a job requires the same variable' do let(:config) do <<-EOY @@ -2423,16 +2440,6 @@ RSpec.describe Ci::CreatePipelineService do expect(pipeline).to be_persisted expect(build_names).to contain_exactly('build', 'test1', 'test2') end - - context 'when FF ci_seed_block_run_before_workflow_rules is disabled' do - before do - stub_feature_flags(ci_seed_block_run_before_workflow_rules: false) - end - - it 'does not a pipeline' do - expect(pipeline).not_to be_persisted - end - end end end @@ -2443,16 +2450,6 @@ RSpec.describe Ci::CreatePipelineService do expect(pipeline).not_to be_persisted end - context 'when FF ci_seed_block_run_before_workflow_rules is disabled' do - before do - stub_feature_flags(ci_seed_block_run_before_workflow_rules: false) - end - - it 'does not create a pipeline' do - expect(pipeline).not_to be_persisted - end - end - context 'when a job requires the same variable' do let(:config) do <<-EOY @@ -2480,16 +2477,6 @@ RSpec.describe Ci::CreatePipelineService do it 'does not create a pipeline' do expect(pipeline).not_to be_persisted end - - context 'when FF ci_seed_block_run_before_workflow_rules is disabled' do - before do - stub_feature_flags(ci_seed_block_run_before_workflow_rules: false) - end - - it 'does not create a pipeline' do - expect(pipeline).not_to be_persisted - end - end end end end |