diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-16 15:07:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-16 15:07:43 +0300 |
commit | d10a462fedbd7794a83abdba9b4526600f71de5b (patch) | |
tree | 4dbd21cb89013d9e07b05bac5101cd13585a8be5 /spec/services/ci | |
parent | 13867d66e92c2fd8962a126db4fbdc32891343c9 (diff) |
Add latest changes from gitlab-org/gitlab@masterogolowinski-master-patch-80898
Diffstat (limited to 'spec/services/ci')
8 files changed, 39 insertions, 53 deletions
diff --git a/spec/services/ci/archive_trace_service_spec.rb b/spec/services/ci/archive_trace_service_spec.rb index 64fa74ccce5..ba94013b574 100644 --- a/spec/services/ci/archive_trace_service_spec.rb +++ b/spec/services/ci/archive_trace_service_spec.rb @@ -41,7 +41,9 @@ describe Ci::ArchiveTraceService, '#execute' do context 'when job failed to archive trace but did not raise an exception' do before do - allow_any_instance_of(Gitlab::Ci::Trace).to receive(:archive!) {} + allow_next_instance_of(Gitlab::Ci::Trace) do |instance| + allow(instance).to receive(:archive!) {} + end end it 'leaves a warning message in sidekiq log' do @@ -59,7 +61,7 @@ describe Ci::ArchiveTraceService, '#execute' do let(:job) { create(:ci_build, :running, :trace_live) } it 'increments Prometheus counter, sends crash report to Sentry and ignore an error for continuing to archive' do - expect(Gitlab::Sentry) + expect(Gitlab::ErrorTracking) .to receive(:track_and_raise_for_dev_exception) .with(::Gitlab::Ci::Trace::ArchiveError, issue_url: 'https://gitlab.com/gitlab-org/gitlab-foss/issues/51502', diff --git a/spec/services/ci/create_pipeline_service/rules_spec.rb b/spec/services/ci/create_pipeline_service/rules_spec.rb index 2c93007f8e8..0a2c5724ce4 100644 --- a/spec/services/ci/create_pipeline_service/rules_spec.rb +++ b/spec/services/ci/create_pipeline_service/rules_spec.rb @@ -13,7 +13,9 @@ describe Ci::CreatePipelineService do context 'job:rules' do before do stub_ci_pipeline_yaml_file(config) - allow_any_instance_of(Ci::BuildScheduleWorker).to receive(:perform).and_return(true) + allow_next_instance_of(Ci::BuildScheduleWorker) do |instance| + allow(instance).to receive(:perform).and_return(true) + end end context 'exists:' do @@ -98,6 +100,17 @@ describe Ci::CreatePipelineService do stub_ci_pipeline_yaml_file(config) end + shared_examples 'workflow:rules feature disabled' do + before do + stub_feature_flags(workflow_rules: false) + end + + it 'presents a message that rules are disabled' do + expect(pipeline.errors[:base]).to include('Workflow rules are disabled') + expect(pipeline).to be_persisted + end + end + context 'with a single regex-matching if: clause' do let(:config) do <<-EOY @@ -229,16 +242,7 @@ describe Ci::CreatePipelineService do expect(pipeline).not_to be_persisted end - context 'with workflow:rules shut off' do - before do - stub_feature_flags(workflow_rules: false) - end - - 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 + it_behaves_like 'workflow:rules feature disabled' end context 'where workflow passes and the job passes' do @@ -249,16 +253,7 @@ describe Ci::CreatePipelineService do expect(pipeline).to be_persisted end - context 'with workflow:rules shut off' do - before do - stub_feature_flags(workflow_rules: false) - end - - it 'saves a pending pipeline' do - expect(pipeline).to be_pending - expect(pipeline).to be_persisted - end - end + it_behaves_like 'workflow:rules feature disabled' end context 'where workflow fails and the job fails' do @@ -269,16 +264,7 @@ describe Ci::CreatePipelineService do expect(pipeline).not_to be_persisted end - context 'with workflow:rules shut off' do - before do - stub_feature_flags(workflow_rules: false) - end - - 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 + it_behaves_like 'workflow:rules feature disabled' end context 'where workflow fails and the job passes' do @@ -289,16 +275,7 @@ describe Ci::CreatePipelineService do expect(pipeline).not_to be_persisted end - context 'with workflow:rules shut off' do - before do - stub_feature_flags(workflow_rules: false) - end - - it 'saves a pending pipeline' do - expect(pipeline).to be_pending - expect(pipeline).to be_persisted - end - end + it_behaves_like 'workflow:rules feature disabled' end end end diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index c4274f0bd17..4f624368215 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -528,7 +528,7 @@ describe Ci::CreatePipelineService do end it 'logs error' do - expect(Gitlab::Sentry).to receive(:track_exception).and_call_original + expect(Gitlab::ErrorTracking).to receive(:track_exception).and_call_original execute_service end @@ -613,7 +613,7 @@ describe Ci::CreatePipelineService do end it 'logs error' do - expect(Gitlab::Sentry).to receive(:track_exception).and_call_original + expect(Gitlab::ErrorTracking).to receive(:track_exception).and_call_original execute_service end diff --git a/spec/services/ci/pipeline_trigger_service_spec.rb b/spec/services/ci/pipeline_trigger_service_spec.rb index 24d42f402f4..44ce1ff699b 100644 --- a/spec/services/ci/pipeline_trigger_service_spec.rb +++ b/spec/services/ci/pipeline_trigger_service_spec.rb @@ -45,7 +45,9 @@ describe Ci::PipelineTriggerService do context 'when commit message has [ci skip]' do before do - allow_any_instance_of(Ci::Pipeline).to receive(:git_commit_message) { '[ci skip]' } + allow_next_instance_of(Ci::Pipeline) do |instance| + allow(instance).to receive(:git_commit_message) { '[ci skip]' } + end end it 'ignores [ci skip] and create as general' do @@ -124,7 +126,9 @@ describe Ci::PipelineTriggerService do context 'when commit message has [ci skip]' do before do - allow_any_instance_of(Ci::Pipeline).to receive(:git_commit_message) { '[ci skip]' } + allow_next_instance_of(Ci::Pipeline) do |instance| + allow(instance).to receive(:git_commit_message) { '[ci skip]' } + end end it 'ignores [ci skip] and create as general' do diff --git a/spec/services/ci/play_manual_stage_service_spec.rb b/spec/services/ci/play_manual_stage_service_spec.rb index 5d812745c7f..e2946111a13 100644 --- a/spec/services/ci/play_manual_stage_service_spec.rb +++ b/spec/services/ci/play_manual_stage_service_spec.rb @@ -51,8 +51,9 @@ describe Ci::PlayManualStageService, '#execute' do context 'when user does not have permission on a specific build' do before do - allow_any_instance_of(Ci::Build).to receive(:play) - .and_raise(Gitlab::Access::AccessDeniedError) + allow_next_instance_of(Ci::Build) do |instance| + allow(instance).to receive(:play).and_raise(Gitlab::Access::AccessDeniedError) + end service.execute(stage) end diff --git a/spec/services/ci/prepare_build_service_spec.rb b/spec/services/ci/prepare_build_service_spec.rb index 87061b3b15a..3c3d8b90bb0 100644 --- a/spec/services/ci/prepare_build_service_spec.rb +++ b/spec/services/ci/prepare_build_service_spec.rb @@ -51,7 +51,7 @@ describe Ci::PrepareBuildService do it 'drops the build and notifies Sentry' do expect(build).to receive(:drop).with(:unmet_prerequisites).once - expect(Gitlab::Sentry).to receive(:track_exception) + expect(Gitlab::ErrorTracking).to receive(:track_exception) .with(instance_of(Kubeclient::HttpError), hash_including(build_id: build.id)) subject diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb index a15a0afc526..ba5891c8694 100644 --- a/spec/services/ci/process_pipeline_service_spec.rb +++ b/spec/services/ci/process_pipeline_service_spec.rb @@ -426,7 +426,9 @@ describe Ci::ProcessPipelineService, '#execute' do before do successful_build('test', stage_idx: 0) - allow_any_instance_of(Ci::PersistentRef).to receive(:delete_refs) { raise ArgumentError } + allow_next_instance_of(Ci::PersistentRef) do |instance| + allow(instance).to receive(:delete_refs) { raise ArgumentError } + end end it 'process the pipeline' do diff --git a/spec/services/ci/register_job_service_spec.rb b/spec/services/ci/register_job_service_spec.rb index aa31d98c4fb..0339c6cc2d6 100644 --- a/spec/services/ci/register_job_service_spec.rb +++ b/spec/services/ci/register_job_service_spec.rb @@ -514,7 +514,7 @@ module Ci subject { execute(specific_runner, {}) } it 'does drop the build and logs both failures' do - expect(Gitlab::Sentry).to receive(:track_exception) + expect(Gitlab::ErrorTracking).to receive(:track_exception) .with(anything, a_hash_including(build_id: pending_job.id)) .twice .and_call_original @@ -540,7 +540,7 @@ module Ci subject { execute(specific_runner, {}) } it 'does drop the build and logs failure' do - expect(Gitlab::Sentry).to receive(:track_exception) + expect(Gitlab::ErrorTracking).to receive(:track_exception) .with(anything, a_hash_including(build_id: pending_job.id)) .once .and_call_original |