diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-16 21:14:09 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-12-16 21:14:09 +0300 |
commit | cab5a484fe5153edc5463603923491b1487faa5f (patch) | |
tree | 70ab8059b964452839165c99a48d2223536ca769 /spec/services | |
parent | 6aaec2fc6c3e3f96f443b96fd53ae9ed5e7979af (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/projects/destroy_service_spec.rb | 64 |
1 files changed, 14 insertions, 50 deletions
diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb index 18bcfe3f3b4..9ffc32025a4 100644 --- a/spec/services/projects/destroy_service_spec.rb +++ b/spec/services/projects/destroy_service_spec.rb @@ -55,22 +55,6 @@ RSpec.describe Projects::DestroyService, :aggregate_failures do .and change { Ci::Pipeline.count }.by(-1) end - context 'with abort_deleted_project_pipelines disabled' do - stub_feature_flags(abort_deleted_project_pipelines: false) - - it 'avoids N+1 queries' do - recorder = ActiveRecord::QueryRecorder.new { destroy_project(project, user, {}) } - - project = create(:project, :repository, namespace: user.namespace) - pipeline = create(:ci_pipeline, project: project) - builds = create_list(:ci_build, 3, :artifacts, pipeline: pipeline) - create(:ci_pipeline_artifact, pipeline: pipeline) - create_list(:ci_build_trace_chunk, 3, build: builds[0]) - - expect { destroy_project(project, project.owner, {}) }.not_to exceed_query_limit(recorder) - end - end - context 'with ci_optimize_project_records_destruction disabled' do stub_feature_flags(ci_optimize_project_records_destruction: false) @@ -86,7 +70,7 @@ RSpec.describe Projects::DestroyService, :aggregate_failures do end end - context 'with ci_optimize_project_records_destruction and abort_deleted_project_pipelines enabled' do + context 'with ci_optimize_project_records_destruction enabled' do it 'avoids N+1 queries' do recorder = ActiveRecord::QueryRecorder.new { destroy_project(project, user, {}) } @@ -132,27 +116,25 @@ RSpec.describe Projects::DestroyService, :aggregate_failures do destroy_project(project, user, {}) end - context 'with abort_deleted_project_pipelines feature disabled' do - before do - stub_feature_flags(abort_deleted_project_pipelines: false) - end + context 'with running pipelines to be aborted' do + let!(:pipelines) { create_list(:ci_pipeline, 3, :running, project: project) } + let(:destroy_pipeline_service) { double('DestroyPipelineService', execute: nil) } - it 'does not bulk-fail project ci pipelines' do - expect(::Ci::AbortPipelinesService).not_to receive(:new) + it 'executes DestroyPipelineService for project ci pipelines' do + allow(::Ci::DestroyPipelineService).to receive(:new).and_return(destroy_pipeline_service) - destroy_project(project, user, {}) - end + expect(::Ci::AbortPipelinesService) + .to receive_message_chain(:new, :execute) + .with(project.all_pipelines, :project_deleted) - it 'does not destroy CI records via DestroyPipelineService' do - expect(::Ci::DestroyPipelineService).not_to receive(:new) + pipelines.each do |pipeline| + expect(destroy_pipeline_service) + .to receive(:execute) + .with(pipeline) + end destroy_project(project, user, {}) end - end - - context 'with abort_deleted_project_pipelines feature enabled' do - let!(:pipelines) { create_list(:ci_pipeline, 3, :running, project: project) } - let(:destroy_pipeline_service) { double('DestroyPipelineService', execute: nil) } context 'with ci_optimize_project_records_destruction disabled' do before do @@ -173,24 +155,6 @@ RSpec.describe Projects::DestroyService, :aggregate_failures do destroy_project(project, user, {}) end end - - context 'with ci_optimize_project_records_destruction enabled' do - it 'executes DestroyPipelineService for project ci pipelines' do - allow(::Ci::DestroyPipelineService).to receive(:new).and_return(destroy_pipeline_service) - - expect(::Ci::AbortPipelinesService) - .to receive_message_chain(:new, :execute) - .with(project.all_pipelines, :project_deleted) - - pipelines.each do |pipeline| - expect(destroy_pipeline_service) - .to receive(:execute) - .with(pipeline) - end - - destroy_project(project, user, {}) - end - end end context 'when project has remote mirrors' do |