Commit 00b993ae authored by Douwe Maan's avatar Douwe Maan Committed by Lin Jen-Shin

Merge branch 'sh-add-option-to-hard-delete' into 'master'

Hard delete users' associated records deleted from AbuseReports

Closes #31021

See merge request !10723
parent d3db4e04
...@@ -16,7 +16,7 @@ class AbuseReport < ActiveRecord::Base ...@@ -16,7 +16,7 @@ class AbuseReport < ActiveRecord::Base
def remove_user(deleted_by:) def remove_user(deleted_by:)
user.block user.block
DeleteUserWorker.perform_async(deleted_by.id, user.id, delete_solo_owned_groups: true) DeleteUserWorker.perform_async(deleted_by.id, user.id, delete_solo_owned_groups: true, hard_delete: true)
end end
def notify def notify
......
...@@ -26,7 +26,7 @@ module Users ...@@ -26,7 +26,7 @@ module Users
::Projects::DestroyService.new(project, current_user, skip_repo: true).execute ::Projects::DestroyService.new(project, current_user, skip_repo: true).execute
end end
MigrateToGhostUserService.new(user).execute MigrateToGhostUserService.new(user).execute unless options[:hard_delete]
# Destroy the namespace after destroying the user since certain methods may depend on the namespace existing # Destroy the namespace after destroying the user since certain methods may depend on the namespace existing
namespace = user.namespace namespace = user.namespace
......
...@@ -29,7 +29,8 @@ RSpec.describe AbuseReport, type: :model do ...@@ -29,7 +29,8 @@ RSpec.describe AbuseReport, type: :model do
it 'lets a worker delete the user' do it 'lets a worker delete the user' do
expect(DeleteUserWorker).to receive(:perform_async).with(user.id, subject.user.id, expect(DeleteUserWorker).to receive(:perform_async).with(user.id, subject.user.id,
delete_solo_owned_groups: true) delete_solo_owned_groups: true,
hard_delete: true)
subject.remove_user(deleted_by: user) subject.remove_user(deleted_by: user)
end end
......
...@@ -152,6 +152,12 @@ describe Users::DestroyService, services: true do ...@@ -152,6 +152,12 @@ describe Users::DestroyService, services: true do
service.execute(user) service.execute(user)
end end
it 'does not run `MigrateToGhostUser` if hard_delete option is given' do
expect_any_instance_of(Users::MigrateToGhostUserService).not_to receive(:execute)
service.execute(user, hard_delete: true)
end
end end
end end
end 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