Merge pull request #7538 from SuperTux88/fix-account_deleter

Re-add disconnect_contacts in AccountDeleter
This commit is contained in:
Benjamin Neff 2017-08-14 10:28:50 +02:00
commit b447eb6e95
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
3 changed files with 17 additions and 2 deletions

View file

@ -34,6 +34,7 @@ class AccountDeleter
#user deletion methods
remove_share_visibilities_on_contacts_posts
delete_standard_user_associations
disconnect_contacts
tombstone_user
end
@ -68,6 +69,10 @@ class AccountDeleter
end
end
def disconnect_contacts
user.contacts.reload.destroy_all
end
# Currently this would get deleted due to the db foreign key constrainsts,
# but we'll keep this method here for completeness
def remove_share_visibilities_on_contacts_posts

View file

@ -17,7 +17,7 @@ describe AccountDeleter do
user_removal_methods = %i[
delete_standard_user_associations
remove_share_visibilities_on_contacts_posts
tombstone_user
disconnect_contacts tombstone_user
]
person_removal_methods = %i[
@ -108,6 +108,15 @@ describe AccountDeleter do
end
end
context "user associations" do
describe "#disconnect_contacts" do
it "deletes all of user's contacts" do
expect(bob.contacts).to receive(:destroy_all)
@account_deletion.disconnect_contacts
end
end
end
context 'person associations' do
describe '#delete_contacts_of_me' do
it 'deletes all the local contact objects where deleted account is the person' do

View file

@ -60,7 +60,8 @@ class DataGenerator
end
def conversations
a_friend = person.contacts.first.user.person
a_friend = FactoryGirl.create(:contact, person: person).user.person
FactoryGirl.create(:contact, user: user, person: a_friend) unless user.nil?
create_conversation_with_message(a_friend, person, "Subject", "Hey #{person.name}")
create_conversation_with_message(person, a_friend, "Subject", "Hey #{a_friend.name}")
end