Loading lib/account_deleter.rb +5 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ class AccountDeleter #user deletion methods remove_share_visibilities_on_contacts_posts delete_standard_user_associations disconnect_contacts tombstone_user end Loading Loading @@ -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 Loading spec/lib/account_deleter_spec.rb +10 −1 Original line number Diff line number Diff line Loading @@ -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[ Loading Loading @@ -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 Loading spec/support/data_generator.rb +2 −1 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
lib/account_deleter.rb +5 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ class AccountDeleter #user deletion methods remove_share_visibilities_on_contacts_posts delete_standard_user_associations disconnect_contacts tombstone_user end Loading Loading @@ -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 Loading
spec/lib/account_deleter_spec.rb +10 −1 Original line number Diff line number Diff line Loading @@ -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[ Loading Loading @@ -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 Loading
spec/support/data_generator.rb +2 −1 Original line number Diff line number Diff line Loading @@ -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 Loading