Unverified Commit d5d53baa authored by Ashley Nelson's avatar Ashley Nelson Committed by Dennis Schubert
Browse files

Delete user invitation code during account deletion

closes #8202
parent 7a7c48a4
......@@ -5,6 +5,7 @@
## Bug fixes
* Update comment counter when weleting a comment in the Single Post View [#7938](https://github.com/diaspora/diaspora/pull/7938)
* Link diaspora only poduptime list [#8174](https://github.com/diaspora/diaspora/pull/8174)
* Delete a user's invitation code during account deletion [#8202](https://github.com/diaspora/diaspora/pull/8202)
## Features
* Support and recommend TOML as configuration format [#8132](https://github.com/diaspora/diaspora/pull/8132)
......
......@@ -39,6 +39,7 @@ class AccountDeleter
remove_share_visibilities_on_contacts_posts
disconnect_contacts
delete_standard_user_associations
delete_user_invitation_code
tombstone_user
end
......@@ -56,6 +57,10 @@ class AccountDeleter
end
end
def delete_user_invitation_code
InvitationCode.find_by(user_id: user.id).try(:destroy)
end
def normal_ar_person_associates_to_delete
%i[posts photos mentions participations roles blocks conversation_visibilities]
end
......
......@@ -76,6 +76,7 @@ describe AccountDeleter do
describe "#close_user" do
user_removal_methods = %i[
delete_standard_user_associations
delete_user_invitation_code
remove_share_visibilities_on_contacts_posts
disconnect_contacts tombstone_user
]
......@@ -92,7 +93,7 @@ describe AccountDeleter do
end
describe "#delete_standard_user_associations" do
it 'removes all standard user associaltions' do
it "removes all standard user associations" do
@account_deletion.normal_ar_user_associates_to_delete.each do |asso|
association_double = double
expect(association_double).to receive(:ids).and_return([42])
......@@ -107,11 +108,23 @@ describe AccountDeleter do
end
end
describe "#delete_user_invitation_code" do
it "deletes user invitation code" do
expect(bob.invitation_code).not_to be_nil
expect(bob.invitation_code).to eq(InvitationCode.find_by(user_id: bob.id))
invitation_code_double = double
expect(InvitationCode).to receive(:find_by).with(user_id: bob.id).and_return(invitation_code_double)
expect(invitation_code_double).to receive(:destroy)
@account_deletion.delete_user_invitation_code
end
end
describe "#delete_standard_person_associations" do
before do
@account_deletion.person = bob.person
end
it 'removes all standard person associaltions' do
it "removes all standard person associations" do
@account_deletion.normal_ar_person_associates_to_delete.each do |asso|
association_double = double
expect(association_double).to receive(:ids).and_return([42])
......
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