Commit 2e739cee authored by David O'Regan's avatar David O'Regan Committed by Francisco Javier López

Hard delete bulk snippets

When a user deletes a Project, assume they have the
right permissions to delete its resources and trigger
a hard delete for snippets.

Changelog: fixed
parent c9d6d99d
......@@ -72,7 +72,9 @@ module Projects
end
def remove_snippets
response = ::Snippets::BulkDestroyService.new(current_user, project.snippets).execute
# We're setting the hard_delete param because we dont need to perform the access checks within the service since
# the user has enough access rights to remove the project and its resources.
response = ::Snippets::BulkDestroyService.new(current_user, project.snippets).execute(hard_delete: true)
if response.error?
log_error("Snippet deletion failed on #{project.full_path} with the following message: #{response.message}")
......
......@@ -437,11 +437,12 @@ RSpec.describe Projects::DestroyService, :aggregate_failures do
destroy_project(project, user)
end
it 'calls the bulk snippet destroy service' do
it 'calls the bulk snippet destroy service with the hard_delete param set to true' do
expect(project.snippets.count).to eq 2
expect(Snippets::BulkDestroyService).to receive(:new)
.with(user, project.snippets).and_call_original
expect_next_instance_of(Snippets::BulkDestroyService, user, project.snippets) do |instance|
expect(instance).to receive(:execute).with(hard_delete: true).and_call_original
end
expect do
destroy_project(project, user)
......
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