Fix a failing spec under 1.9 in receive_spec

This commit is contained in:
Sarah Mei 2010-11-15 21:19:21 -08:00
parent 0b12c4e272
commit 9fa47c9bfa
3 changed files with 635 additions and 630 deletions

View file

@ -94,19 +94,23 @@ module Diaspora
def remove_contact(bad_contact)
contact = contact_for(bad_contact)
contact.aspects.each{|aspect|
contact.aspects.each do |aspect|
contact.aspects.delete(aspect)
aspect.posts.each { |post|
aspect.posts.each do |post|
aspect.post_ids.delete(post.id) if post.person == bad_contact
}
end
aspect.save
}
end
self.raw_visible_posts.find_all_by_person_id( bad_contact.id ).each{|post|
self.raw_visible_posts.find_all_by_person_id(bad_contact.id).each do |post|
self.visible_post_ids.delete(post.id)
post.user_refs -= 1
(post.user_refs > 0 || post.person.owner.nil? == false) ? post.save : post.destroy
}
if (post.user_refs > 0) || post.person.owner.nil? == false
post.save
else
post.destroy
end
end
self.save
raise "Contact not deleted" unless contact.destroy
bad_contact.save

1318
spec/fixtures/users.yaml vendored

File diff suppressed because it is too large Load diff

View file

@ -100,6 +100,7 @@ describe User do
it 'should be remove a post if the noone links to it' do
person = user2.person
user2.delete
person.reload
lambda {user.disconnect(person)}.should change(Post, :count).by(-1)
end