remove depricated methods

This commit is contained in:
danielgrippi 2012-01-18 13:29:43 -08:00
parent c82ac5f3e2
commit 5721c9e512
4 changed files with 1 additions and 165 deletions

View file

@ -51,7 +51,6 @@ class Person < ActiveRecord::Base
has_many :mentions, :dependent => :destroy has_many :mentions, :dependent => :destroy
before_destroy :remove_all_traces
before_validation :clean_url before_validation :clean_url
validates :url, :presence => true validates :url, :presence => true
@ -322,10 +321,6 @@ class Person < ActiveRecord::Base
end end
private 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 def fix_profile
Webfinger.new(self.diaspora_handle).fetch Webfinger.new(self.diaspora_handle).fetch
self.reload self.reload

View file

@ -130,7 +130,6 @@ class User < ActiveRecord::Base
end end
end end
def toggle_hidden_shareable(share) def toggle_hidden_shareable(share)
share_id = share.id.to_s share_id = share.id.to_s
key = share.class.base_class.to_s key = share.class.base_class.to_s
@ -166,7 +165,6 @@ class User < ActiveRecord::Base
Resque.enqueue(Jobs::ResetPassword, self.id) Resque.enqueue(Jobs::ResetPassword, self.id)
end end
def update_user_preferences(pref_hash) def update_user_preferences(pref_hash)
if self.disable_mail if self.disable_mail
UserPreference::VALID_EMAIL_TYPES.each{|x| self.user_preferences.find_or_create_by_email_type(x)} 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 aq
end end
def encryption_key def encryption_key
OpenSSL::PKey::RSA.new(serialized_private_key) OpenSSL::PKey::RSA.new(serialized_private_key)
end end
@ -459,32 +456,6 @@ class User < ActiveRecord::Base
AppConfig[:admins].present? && AppConfig[:admins].include?(self.username) AppConfig[:admins].present? && AppConfig[:admins].include?(self.username)
end 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 def guard_unconfirmed_email
self.unconfirmed_email = nil if unconfirmed_email.blank? || unconfirmed_email == email self.unconfirmed_email = nil if unconfirmed_email.blank? || unconfirmed_email == email
@ -501,7 +472,6 @@ class User < ActiveRecord::Base
end end
end end
# Generate public/private keys for User and associated Person # Generate public/private keys for User and associated Person
def generate_keys def generate_keys
key_size = (Rails.env == 'test' ? 512 : 4096) key_size = (Rails.env == 'test' ? 512 : 4096)

View file

@ -135,7 +135,7 @@ describe Person do
it 'does not include www if it is set in app config' do it 'does not include www if it is set in app config' do
old_url = AppConfig[:pod_url] 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 = User.build(:username => "foo123", :email => "foo123@example.com", :password => "password", :password_confirmation => "password").person
new_person.diaspora_handle.should == "foo123@foobar.com" new_person.diaspora_handle.should == "foo123@foobar.com"
AppConfig[:pod_url] = old_url AppConfig[:pod_url] = old_url
@ -230,43 +230,6 @@ describe Person do
person_two.owns?(person_message).should be false person_two.owns?(person_message).should be false
end 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 describe "disconnecting" do
before do before do
@user2 = Factory(:user) @user2 = Factory(:user)

View file

@ -618,29 +618,6 @@ describe User do
end end
describe 'account deletion' do 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 describe '#destroy' do
it 'removes invitations from the user' do it 'removes invitations from the user' do
Factory(:invitation, :sender => alice) Factory(:invitation, :sender => alice)
@ -665,75 +642,6 @@ describe User do
}.by(-1) }.by(-1)
end end
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 end
describe '#mail' do describe '#mail' do