Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-22 00:09:40 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-22 00:09:40 +0300
commitdb115d5ac71e57b2dad327004de7660e353dcd1c (patch)
tree440519fe8dd6439577258fa671274d6b9a0d7813 /spec/services
parentaed8f5ecc5f9a09e3af9c32f7b02743d317a4116 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/packages/rubygems/dependency_resolver_service_spec.rb2
-rw-r--r--spec/services/projects/destroy_service_spec.rb48
2 files changed, 49 insertions, 1 deletions
diff --git a/spec/services/packages/rubygems/dependency_resolver_service_spec.rb b/spec/services/packages/rubygems/dependency_resolver_service_spec.rb
index 206bffe53f8..78abfc96ed5 100644
--- a/spec/services/packages/rubygems/dependency_resolver_service_spec.rb
+++ b/spec/services/packages/rubygems/dependency_resolver_service_spec.rb
@@ -92,7 +92,7 @@ RSpec.describe Packages::Rubygems::DependencyResolverService do
]
}]
- expect(subject.payload).to eq(expected_result)
+ expect(subject.payload).to match_array(expected_result)
end
end
end
diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb
index b2a68bbd0aa..ff582279d71 100644
--- a/spec/services/projects/destroy_service_spec.rb
+++ b/spec/services/projects/destroy_service_spec.rb
@@ -418,6 +418,54 @@ RSpec.describe Projects::DestroyService, :aggregate_failures do
end
end
+ context 'when project has webhooks' do
+ let!(:web_hook1) { create(:project_hook, project: project) }
+ let!(:web_hook2) { create(:project_hook, project: project) }
+ let!(:another_project_web_hook) { create(:project_hook) }
+ let!(:web_hook_log) { create(:web_hook_log, web_hook: web_hook1) }
+
+ it 'deletes webhooks and logs related to project' do
+ expect_next_instance_of(WebHooks::DestroyService, user) do |instance|
+ expect(instance).to receive(:sync_destroy).with(web_hook1).and_call_original
+ end
+ expect_next_instance_of(WebHooks::DestroyService, user) do |instance|
+ expect(instance).to receive(:sync_destroy).with(web_hook2).and_call_original
+ end
+
+ expect do
+ destroy_project(project, user)
+ end.to change(WebHook, :count).by(-2)
+ .and change(WebHookLog, :count).by(-1)
+ end
+
+ context 'when an error is raised deleting webhooks' do
+ before do
+ allow_next_instance_of(WebHooks::DestroyService) do |instance|
+ allow(instance).to receive(:sync_destroy).and_return(message: 'foo', status: :error)
+ end
+ end
+
+ it_behaves_like 'handles errors thrown during async destroy', "Failed to remove webhooks"
+ end
+
+ context 'when "destroy_webhooks_before_the_project" flag is disabled' do
+ before do
+ stub_feature_flags(destroy_webhooks_before_the_project: false)
+ end
+
+ it 'does not call WebHooks::DestroyService' do
+ expect(WebHooks::DestroyService).not_to receive(:new)
+
+ expect do
+ destroy_project(project, user)
+ end.to change(WebHook, :count).by(-2)
+ .and change(WebHookLog, :count).by(-1)
+
+ expect(another_project_web_hook.reload).to be
+ end
+ end
+ end
+
context 'error while destroying', :sidekiq_inline do
let!(:pipeline) { create(:ci_pipeline, project: project) }
let!(:builds) { create_list(:ci_build, 2, :artifacts, pipeline: pipeline) }