FIX: Destroy invites of anonymized emails (#13404)
Anonymizing a user changed their email address, destroyed all associated InvitedUser records, but did not destroy the invites associated to user's email.
This commit is contained in:
parent
aa4f0aee67
commit
c893b20298
|
@ -16,6 +16,7 @@ module Jobs
|
||||||
def make_anonymous
|
def make_anonymous
|
||||||
anonymize_ips(@anonymize_ip) if @anonymize_ip
|
anonymize_ips(@anonymize_ip) if @anonymize_ip
|
||||||
|
|
||||||
|
Invite.where(email: @prev_email).destroy_all
|
||||||
InvitedUser.where(user_id: @user_id).destroy_all
|
InvitedUser.where(user_id: @user_id).destroy_all
|
||||||
EmailToken.where(user_id: @user_id).destroy_all
|
EmailToken.where(user_id: @user_id).destroy_all
|
||||||
EmailLog.where(user_id: @user_id).delete_all
|
EmailLog.where(user_id: @user_id).delete_all
|
||||||
|
|
|
@ -368,4 +368,17 @@ describe UserAnonymizer do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "anonymize_emails" do
|
||||||
|
it "destroys all associated invites" do
|
||||||
|
invite = Fabricate(:invite, email: 'test@example.com')
|
||||||
|
user = invite.redeem
|
||||||
|
|
||||||
|
Jobs.run_immediately!
|
||||||
|
described_class.make_anonymous(user, admin)
|
||||||
|
|
||||||
|
expect(user.email).not_to eq('test@example.com')
|
||||||
|
expect(Invite.exists?(id: invite.id)).to eq(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue