Hard delete users' associated records deleted from AbuseReports
In the case of spammers, we really want a hard delete to avoid retaining spam. Closes #31021
This commit is contained in:
parent
309bab4310
commit
60eee739f0
4 changed files with 10 additions and 3 deletions
|
@ -16,7 +16,7 @@ class AbuseReport < ActiveRecord::Base
|
|||
|
||||
def remove_user(deleted_by:)
|
||||
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
|
||||
|
||||
def notify
|
||||
|
|
|
@ -26,7 +26,7 @@ module Users
|
|||
::Projects::DestroyService.new(project, current_user, skip_repo: true).execute
|
||||
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
|
||||
namespace = user.namespace
|
||||
|
|
|
@ -29,7 +29,8 @@ RSpec.describe AbuseReport, type: :model do
|
|||
|
||||
it 'lets a worker delete the user' do
|
||||
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)
|
||||
end
|
||||
|
|
|
@ -152,6 +152,12 @@ describe Users::DestroyService, services: true do
|
|||
|
||||
service.execute(user)
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue