diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb index d96330ba22eece19106e2d9c838b8424b0bd4c9f..c736070dd8e276991f00f9ae9c5520c124107786 100644 --- a/app/services/projects/destroy_service.rb +++ b/app/services/projects/destroy_service.rb @@ -74,6 +74,10 @@ def trash_relation_repositories! def remove_snippets response = ::Snippets::BulkDestroyService.new(current_user, project.snippets).execute + if response.error? + log_error("Snippet deletion failed on #{project.full_path} with the following message: #{response.message}") + end + response.success? end diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb index 3d361f76af251f1a1da25d3d517b2cb5f9e50251..8e842e4797e1f0b77603c3088ef0ca49a45a9c5f 100644 --- a/spec/services/projects/destroy_service_spec.rb +++ b/spec/services/projects/destroy_service_spec.rb @@ -449,11 +449,15 @@ end context 'when an error is raised deleting snippets' do + let(:error_message) { 'foo' } + it 'does not delete project' do allow_next_instance_of(Snippets::BulkDestroyService) do |instance| - allow(instance).to receive(:execute).and_return(ServiceResponse.error(message: 'foo')) + allow(instance).to receive(:execute).and_return(ServiceResponse.error(message: error_message)) end + expect(Gitlab::AppLogger).to receive(:error).with("Snippet deletion failed on #{project.full_path} with the following message: #{error_message}") + expect(Gitlab::AppLogger).to receive(:error).with(/Failed to remove project snippets/) expect(destroy_project(project, user)).to be_falsey expect(project.gitlab_shell.repository_exists?(project.repository_storage, path + '.git')).to be_truthy end