diff --git a/app/models/person.rb b/app/models/person.rb index 3d9496a2e..55fd3fa17 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -51,7 +51,6 @@ class Person < ActiveRecord::Base has_many :mentions, :dependent => :destroy - before_destroy :remove_all_traces before_validation :clean_url validates :url, :presence => true @@ -322,10 +321,6 @@ class Person < ActiveRecord::Base end private - def remove_all_traces - Notification.joins(:notification_actors).where(:notification_actors => {:person_id => self.id}).all.each{ |n| n.destroy} - end - def fix_profile Webfinger.new(self.diaspora_handle).fetch self.reload diff --git a/app/models/user.rb b/app/models/user.rb index 3ba7864fc..1fc56abf9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -130,7 +130,6 @@ class User < ActiveRecord::Base end end - def toggle_hidden_shareable(share) share_id = share.id.to_s key = share.class.base_class.to_s @@ -166,7 +165,6 @@ class User < ActiveRecord::Base Resque.enqueue(Jobs::ResetPassword, self.id) end - def update_user_preferences(pref_hash) if self.disable_mail UserPreference::VALID_EMAIL_TYPES.each{|x| self.user_preferences.find_or_create_by_email_type(x)} @@ -450,7 +448,6 @@ class User < ActiveRecord::Base aq end - def encryption_key OpenSSL::PKey::RSA.new(serialized_private_key) end @@ -459,32 +456,6 @@ class User < ActiveRecord::Base AppConfig[:admins].present? && AppConfig[:admins].include?(self.username) end - def remove_all_traces - disconnect_everyone - remove_mentions - remove_person - end - - def remove_person - self.person.destroy - end - - def disconnect_everyone - self.contacts.each do |contact| - if contact.person.remote? - self.disconnect(contact) - else - contact.person.owner.disconnected_by(self.person) - remove_contact(contact, :force => true) - end - end - self.aspects.destroy_all - end - - def remove_mentions - Mention.where( :person_id => self.person.id).delete_all - end - def guard_unconfirmed_email self.unconfirmed_email = nil if unconfirmed_email.blank? || unconfirmed_email == email @@ -501,7 +472,6 @@ class User < ActiveRecord::Base end end - # Generate public/private keys for User and associated Person def generate_keys key_size = (Rails.env == 'test' ? 512 : 4096) diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index ee2043ff2..49a4f5751 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -135,7 +135,7 @@ describe Person do it 'does not include www if it is set in app config' do old_url = AppConfig[:pod_url] - AppConfig[:pod_url] = 'https://www.foobar.com/' + AppConfig[:pod_url] = 'https://www.foobar.com/' new_person = User.build(:username => "foo123", :email => "foo123@example.com", :password => "password", :password_confirmation => "password").person new_person.diaspora_handle.should == "foo123@foobar.com" AppConfig[:pod_url] = old_url @@ -230,43 +230,6 @@ describe Person do person_two.owns?(person_message).should be false end - describe '#remove_all_traces' do - before do - @deleter = Factory(:person) - @status = Factory.create(:status_message, :author => @deleter) - @other_status = Factory.create(:status_message, :author => @person) - end - - it "deletes all notifications from a person's actions" do - note = Factory(:notification, :actors => [@deleter], :recipient => @user) - @deleter.destroy - Notification.where(:id => note.id).first.should be_nil - end - - it "deletes all contacts pointing towards a person" do - @user.contacts.create(:person => @deleter, :aspects => [@user.aspects.first]) - @deleter.destroy - @user.contact_for(@deleter).should be_nil - end - - it "deletes all of a person's posts upon person deletion" do - lambda { @deleter.destroy }.should change(Post, :count).by(-1) - end - - it "deletes a person's profile" do - lambda { - @deleter.destroy - }.should change(Profile, :count).by(-1) - end - - it "deletes a person's comments on person deletion" do - Factory.create(:comment, :author_id => @deleter.id, :diaspora_handle => @deleter.diaspora_handle, :text => "i love you", :post => @other_status) - Factory.create(:comment, :author_id => @person.id, :diaspora_handle => @person.diaspora_handle, :text => "you are creepy", :post => @other_status) - - lambda { @deleter.destroy }.should change(Comment, :count).by(-1) - end - end - describe "disconnecting" do before do @user2 = Factory(:user) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index e0a3633c6..11e707a5b 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -618,29 +618,6 @@ describe User do end describe 'account deletion' do - describe '#remove_all_traces' do - it 'should disconnect everyone' do - alice.should_receive(:disconnect_everyone) - alice.remove_all_traces - end - - it 'should remove mentions' do - alice.should_receive(:remove_mentions) - alice.remove_all_traces - end - - it 'should remove person' do - alice.should_receive(:remove_person) - alice.remove_all_traces - end - - it 'should remove all aspects' do - lambda { - alice.remove_all_traces - }.should change{ alice.aspects(true).count }.by(-1) - end - end - describe '#destroy' do it 'removes invitations from the user' do Factory(:invitation, :sender => alice) @@ -665,75 +642,6 @@ describe User do }.by(-1) end end - - describe '#remove_person' do - it 'should remove the person object' do - person = alice.person - alice.remove_person - person.reload - person.should be_nil - end - - it 'should remove the posts' do - message = alice.post(:status_message, :text => "hi", :to => alice.aspects.first.id) - alice.reload - alice.remove_person - expect { message.reload }.to raise_error ActiveRecord::RecordNotFound - end - end - - describe '#remove_mentions' do - it 'should remove the mentions' do - person = alice.person - sm = Factory(:status_message) - mention = Mention.create(:person => person, :post=> sm) - alice.reload - alice.remove_mentions - expect { mention.reload }.to raise_error ActiveRecord::RecordNotFound - end - end - - describe '#disconnect_everyone' do - it 'has no error on a local friend who has deleted his account' do - d = Factory(:account_deletion, :person => alice.person) - Jobs::DeleteAccount.perform(d.id) - lambda { - bob.disconnect_everyone - }.should_not raise_error - end - - it 'has no error when the user has sent local requests' do - alice.share_with(eve.person, alice.aspects.first) - lambda { - alice.disconnect_everyone - }.should_not raise_error - end - - it 'sends retractions to remote poeple' do - person = eve.person - eve.delete - person.owner_id = nil - person.save - alice.contacts.create(:person => person, :aspects => [alice.aspects.first]) - - alice.should_receive(:disconnect).once - alice.disconnect_everyone - end - - it 'disconnects local people' do - lambda { - alice.remove_all_traces - }.should change{bob.reload.contacts.count}.by(-1) - end - - it 'removes all contacts' do - lambda { - alice.disconnect_everyone - }.should change { - alice.contacts.count - }.by(-1) - end - end end describe '#mail' do