Clean up specs a little, fix unfriending

This commit is contained in:
Raphael 2010-10-20 10:28:08 -07:00
parent 1bd54aba63
commit 0758f9245f
3 changed files with 13 additions and 14 deletions

View file

@ -89,7 +89,10 @@ module Diaspora
def remove_friend(bad_friend) def remove_friend(bad_friend)
raise "Friend not deleted" unless self.friend_ids.delete( bad_friend.id ) raise "Friend not deleted" unless self.friend_ids.delete( bad_friend.id )
aspects.each{|aspect| aspects.each{|aspect|
aspect.person_ids.delete( bad_friend.id )} if aspect.person_ids.delete( bad_friend.id )
aspect.posts.delete_if { |post|
post.person_id == bad_friend.id}
end}
self.save self.save
self.raw_visible_posts.find_all_by_person_id( bad_friend.id ).each{|post| self.raw_visible_posts.find_all_by_person_id( bad_friend.id ).each{|post|

View file

@ -153,7 +153,7 @@ describe Diaspora::Parser do
person.save person.save
#Cache profile for checking against marshaled profile #Cache profile for checking against marshaled profile
old_profile = person.profile old_profile = person.profile.dup
old_profile.first_name.should == 'bob' old_profile.first_name.should == 'bob'
#Build xml for profile, clear profile #Build xml for profile, clear profile

View file

@ -160,22 +160,18 @@ describe User do
describe 'unfriending' do describe 'unfriending' do
before do before do
friend_users(user,aspect, user2, aspect2) friend_users(user,aspect, user2, aspect2)
user.reload
user2.reload
end end
it 'should unfriend the other user on the same seed' do it 'should unfriend the other user on the same seed' do
user.friends.count.should == 1 lambda {user2.unfriend user.person}.should change{
user2.friends.count.should == 1 user2.friends.count}.by(-1)
aspect2.people.count.should == 0
end
user2.unfriend user.person it 'is unfriended by another user' do
user2.reload lambda {user.unfriended_by user2.person}.should change{
user.friends.count}.by(-1)
user2.friends.count.should == 0 aspect.people.count.should == 0
user.unfriended_by user2.person
aspect.reload.people.count.should == 0
aspect2.reload.people.count.should == 0
end end
context 'with a post' do context 'with a post' do