Unverified Commit b447eb6e authored by Benjamin Neff's avatar Benjamin Neff
Browse files

Merge pull request #7538 from SuperTux88/fix-account_deleter

Re-add disconnect_contacts in AccountDeleter
parents 064b4093 a61d5739
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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
+10 −1
Original line number Diff line number Diff line
@@ -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
+2 −1
Original line number Diff line number Diff line
@@ -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