diff options
Diffstat (limited to 'spec/services')
3 files changed, 45 insertions, 10 deletions
diff --git a/spec/services/ci/create_cross_project_pipeline_service_spec.rb b/spec/services/ci/create_cross_project_pipeline_service_spec.rb index 51cf18f8d87..09d44bcea0a 100644 --- a/spec/services/ci/create_cross_project_pipeline_service_spec.rb +++ b/spec/services/ci/create_cross_project_pipeline_service_spec.rb @@ -109,7 +109,7 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do expect(pipeline.source_bridge).to be_a ::Ci::Bridge end - it 'updates bridge status when downstream pipeline gets proceesed' do + it 'updates bridge status when downstream pipeline gets processed' do pipeline = service.execute(bridge) expect(pipeline.reload).to be_pending @@ -128,6 +128,37 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do end end + context 'when downstream pipeline has yaml configuration error' do + before do + stub_ci_pipeline_yaml_file(YAML.dump(job: { invalid: 'yaml' })) + end + + it 'creates only one new pipeline' do + expect { service.execute(bridge) } + .to change { Ci::Pipeline.count }.by(1) + end + + it 'creates a new pipeline in a downstream project' do + pipeline = service.execute(bridge) + + expect(pipeline.user).to eq bridge.user + expect(pipeline.project).to eq downstream_project + expect(bridge.sourced_pipelines.first.pipeline).to eq pipeline + expect(pipeline.triggered_by_pipeline).to eq upstream_pipeline + expect(pipeline.source_bridge).to eq bridge + expect(pipeline.source_bridge).to be_a ::Ci::Bridge + end + + it 'does not update bridge status when downstream pipeline gets processed' do + pipeline = service.execute(bridge) + + expect(pipeline.reload).to be_failed + # TODO: This should change to failed once #198354 gets fixed. + # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/25706 + expect(bridge.reload).to be_pending + end + end + context 'when downstream project is the same as the job project' do let(:trigger) do { trigger: { project: upstream_project.full_path } } @@ -173,7 +204,7 @@ describe Ci::CreateCrossProjectPipelineService, '#execute' do expect(pipeline.source_bridge).to be_a ::Ci::Bridge end - it 'updates bridge status when downstream pipeline gets proceesed' do + it 'updates bridge status when downstream pipeline gets processed' do pipeline = service.execute(bridge) expect(pipeline.reload).to be_pending diff --git a/spec/services/ci/create_pipeline_service/custom_config_content_spec.rb b/spec/services/ci/create_pipeline_service/custom_config_content_spec.rb index 33cd6e164b0..2657f1d300a 100644 --- a/spec/services/ci/create_pipeline_service/custom_config_content_spec.rb +++ b/spec/services/ci/create_pipeline_service/custom_config_content_spec.rb @@ -4,18 +4,22 @@ require 'spec_helper' describe Ci::CreatePipelineService do let_it_be(:project) { create(:project, :repository) } let_it_be(:user) { create(:admin) } + let(:upstream_pipeline) { create(:ci_pipeline) } let(:ref) { 'refs/heads/master' } let(:service) { described_class.new(project, user, { ref: ref }) } context 'custom config content' do let(:bridge) do - double(:bridge, yaml_for_downstream: <<~YML - rspec: - script: rspec - custom: - script: custom - YML - ) + create(:ci_bridge, status: 'running', pipeline: upstream_pipeline, project: upstream_pipeline.project).tap do |bridge| + allow(bridge).to receive(:yaml_for_downstream).and_return( + <<~YML + rspec: + script: rspec + custom: + script: custom + YML + ) + end end subject { service.execute(:push, bridge: bridge) } diff --git a/spec/services/error_tracking/issue_details_service_spec.rb b/spec/services/error_tracking/issue_details_service_spec.rb index 9f217deda21..66b8988f8e3 100644 --- a/spec/services/error_tracking/issue_details_service_spec.rb +++ b/spec/services/error_tracking/issue_details_service_spec.rb @@ -27,7 +27,7 @@ describe ErrorTracking::IssueDetailsService do create(:sentry_issue, issue: gitlab_issue, sentry_issue_identifier: detailed_error.id) expect(result[:issue].gitlab_issue).to include( - "http", "/#{project.full_path}/issues/#{gitlab_issue.iid}" + "http", "/#{project.full_path}/-/issues/#{gitlab_issue.iid}" ) end |