diff --git a/app/models/aspect.rb b/app/models/aspect.rb index c3d9de4a11cad8a261f72d670ac967b1ade8b313..97c812f815f1e5889c6992f8aa7574e83ca2c0be 100644 --- a/app/models/aspect.rb +++ b/app/models/aspect.rb @@ -8,7 +8,7 @@ class Aspect < ActiveRecord::Base has_many :aspect_memberships, :dependent => :destroy has_many :contacts, :through => :aspect_memberships - has_many :aspect_visibilities + has_many :aspect_visibilities, :dependent => :destroy has_many :posts, :through => :aspect_visibilities, :source => :shareable, :source_type => 'Post' has_many :photos, :through => :aspect_visibilities, :source => :shareable, :source_type => 'Photo' diff --git a/app/models/contact.rb b/app/models/contact.rb index f064ad929b398f2fde1456457e2793e689fd0a0d..1a428a8982de6c57a432684954fb77f9bc6dc03e 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -11,7 +11,7 @@ class Contact < ActiveRecord::Base delegate :name, :diaspora_handle, :guid, :first_name, to: :person, prefix: true - has_many :aspect_memberships + has_many :aspect_memberships, :dependent => :destroy has_many :aspects, :through => :aspect_memberships has_many :share_visibilities, :source => :shareable, :source_type => 'Post' @@ -51,7 +51,7 @@ class Contact < ActiveRecord::Base Notification.where(:target_type => "Person", :target_id => person_id, :recipient_id => user_id, - :type => "Notifications::StartedSharing").delete_all + :type => "Notifications::StartedSharing").destroy_all end def dispatch_request diff --git a/app/models/mention.rb b/app/models/mention.rb index 58e6f43755471c2a38b18739b489768351622e59..d03ef648327131e45a7dbf25bc83aacd9f823f74 100644 --- a/app/models/mention.rb +++ b/app/models/mention.rb @@ -22,6 +22,6 @@ class Mention < ActiveRecord::Base end def delete_notification - Notification.where(:target_type => self.class.name, :target_id => self.id).delete_all + Notification.where(:target_type => self.class.name, :target_id => self.id).destroy_all end end diff --git a/app/models/photo.rb b/app/models/photo.rb index 0e4b2bb82fe3a8d3317f4d8ec5bf6f9101fbef1a..60494cc063d743bdf5f2ec8522330a97aea8cdf2 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -51,7 +51,7 @@ class Photo < ActiveRecord::Base end def clear_empty_status_message - if self.status_message_guid && self.status_message.text_and_photos_blank? + if self.status_message && self.status_message.text_and_photos_blank? self.status_message.destroy else true diff --git a/lib/account_deleter.rb b/lib/account_deleter.rb index 314201f928dfc91b8541e16af26989e676bf366a..3d869ea8a3b9edfa806b6b3f3b9ecf9fea7a44b2 100644 --- a/lib/account_deleter.rb +++ b/lib/account_deleter.rb @@ -23,20 +23,22 @@ class AccountDeleter end def perform! - #person - delete_standard_person_associations - remove_conversation_visibilities - remove_share_visibilities_on_persons_posts - delete_contacts_of_me - tombstone_person_and_profile - - if self.user - #user deletion methods - remove_share_visibilities_on_contacts_posts - delete_standard_user_associations - disassociate_invitations - disconnect_contacts - tombstone_user + ActiveRecord::Base.transaction do + #person + delete_standard_person_associations + remove_conversation_visibilities + remove_share_visibilities_on_persons_posts + delete_contacts_of_me + tombstone_person_and_profile + + if self.user + #user deletion methods + remove_share_visibilities_on_contacts_posts + delete_standard_user_associations + disassociate_invitations + disconnect_contacts + tombstone_user + end end end @@ -55,13 +57,13 @@ class AccountDeleter def delete_standard_user_associations normal_ar_user_associates_to_delete.each do |asso| - self.user.send(asso).each{|model| model.delete} + self.user.send(asso).each{|model| model.destroy } end end def delete_standard_person_associations normal_ar_person_associates_to_delete.each do |asso| - self.person.send(asso).delete_all + self.person.send(asso).destroy_all end end diff --git a/lib/tasks/accounts.rake b/lib/tasks/accounts.rake index 1fcfbb553916ddcf47a528475734a78599b318b0..91bfd7a02e59a5631f4eaed40bb9e406bc643b77 100644 --- a/lib/tasks/accounts.rake +++ b/lib/tasks/accounts.rake @@ -7,9 +7,9 @@ namespace :accounts do account_delete.perform! end puts "OK." + else + puts "No acccount deletions to run." end - - puts "No acccount deletions to run." end end diff --git a/spec/lib/account_deleter_spec.rb b/spec/lib/account_deleter_spec.rb index 6554bbeec96bae6f8f08707e6e2c1ecbd29e80ac..339224c48d85fa68598bd61a9c8e89e094792c37 100644 --- a/spec/lib/account_deleter_spec.rb +++ b/spec/lib/account_deleter_spec.rb @@ -73,7 +73,7 @@ describe AccountDeleter do it 'removes all standard user associaltions' do @account_deletion.normal_ar_user_associates_to_delete.each do |asso| association_double = double - association_double.should_receive(:delete) + association_double.should_receive(:destroy) bob.should_receive(asso).and_return([association_double]) end @@ -88,7 +88,7 @@ describe AccountDeleter do it 'removes all standard person associaltions' do @account_deletion.normal_ar_person_associates_to_delete.each do |asso| association_double = double - association_double.should_receive(:delete_all) + association_double.should_receive(:destroy_all) bob.person.should_receive(asso).and_return(association_double) end