Commit faea16cc authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '346165-better-snuppet-destroy-logging' into 'master'

Update snippet destroy logging

See merge request gitlab-org/gitlab!81529
parents 15b7f489 c445913f
......@@ -74,6 +74,10 @@ module Projects
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
......
......@@ -449,11 +449,15 @@ RSpec.describe Projects::DestroyService, :aggregate_failures do
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment