diff --git a/app/jobs/regular/anonymize_user.rb b/app/jobs/regular/anonymize_user.rb index 1113476a81b..c078706c044 100644 --- a/app/jobs/regular/anonymize_user.rb +++ b/app/jobs/regular/anonymize_user.rb @@ -16,6 +16,7 @@ module Jobs def make_anonymous anonymize_ips(@anonymize_ip) if @anonymize_ip + Invite.where(email: @prev_email).destroy_all InvitedUser.where(user_id: @user_id).destroy_all EmailToken.where(user_id: @user_id).destroy_all EmailLog.where(user_id: @user_id).delete_all diff --git a/spec/services/user_anonymizer_spec.rb b/spec/services/user_anonymizer_spec.rb index 13079905455..a150d1e1978 100644 --- a/spec/services/user_anonymizer_spec.rb +++ b/spec/services/user_anonymizer_spec.rb @@ -368,4 +368,17 @@ describe UserAnonymizer do 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