Commit c445913f authored by David O'Regan's avatar David O'Regan Committed by Peter Leitzen

Update snippet destroy logging

Allow snippet destroy error
logging to return a more
granular error message from
the response.
parent 1711cbd5
......@@ -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