FIX: Anonymizing a user clears their user status too (#21673)

This commit is contained in:
Natalie Tay 2023-05-22 13:18:09 +08:00 committed by GitHub
parent 95358062fc
commit 07061410d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -60,6 +60,8 @@ class UserAnonymizer
)
end
@user.clear_status!
@user.user_avatar&.destroy!
@user.single_sign_on_record&.destroy!
@user.oauth2_user_infos.destroy_all

View File

@ -107,6 +107,15 @@ RSpec.describe UserAnonymizer do
end
end
it "clears existing user status" do
user_status = Fabricate(:user_status, user: user)
expect do
make_anonymous
user.reload
end.to change { user.user_status }.from(user_status).to(nil)
end
context "when Site Settings require full name" do
before { SiteSetting.full_name_required = true }