diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb index e7960838101fd5fe7e55b8c4d71ba9e068390ee4..a4dcdd38d250ac0d67e53efee9084a475f84bfa0 100644 --- a/lib/diaspora/user/friending.rb +++ b/lib/diaspora/user/friending.rb @@ -86,7 +86,8 @@ module Diaspora def remove_friend(bad_friend) raise "Friend not deleted" unless self.friend_ids.delete( bad_friend.id ) - aspects.each{|g| g.person_ids.delete( bad_friend.id )} + aspects.each{|aspect| + aspect.person_ids.delete( bad_friend.id )} self.save self.raw_visible_posts.find_all_by_person_id( bad_friend.id ).each{|post| diff --git a/spec/models/user/user_friending_spec.rb b/spec/models/user/user_friending_spec.rb index bef8fa416444f203984effe946626c97d19db74e..67ed9f7991272707df656e4d2741ab4636233e4d 100644 --- a/spec/models/user/user_friending_spec.rb +++ b/spec/models/user/user_friending_spec.rb @@ -189,16 +189,14 @@ describe User do @user2 = Factory.create :user @aspect2 = @user2.aspect(:name => "Gross people") - request = @user.send_friend_request_to( @user2, @aspect) - request.reverse_for @user2 - @user2.activate_friend(@user.person, @aspect2) - @user.receive request.to_diaspora_xml - end - - it 'should unfriend the other user on the same seed' do + friend_users(@user, @aspect, @user2, @aspect2) @user.reload @user2.reload + @aspect.reload + @aspect2.reload + end + it 'should unfriend the other user on the same seed' do @user.friends.count.should == 1 @user2.friends.count.should == 1 @@ -212,6 +210,25 @@ describe User do @aspect.people.count.should == 0 @aspect2.people.count.should == 0 end + context 'with a post' do + before do + @message = @user.post(:status_message, :message => "hi", :to => @aspect.id) + @user2.receive @message.to_diaspora_xml.to_s + @user2.unfriend @user.person + @user.unfriended_by @user2.person + @aspect.reload + @aspect2.reload + @user.reload + @user2.reload + end + it "deletes the unfriended user's posts from visible_posts" do + @user.raw_visible_posts.include?(@message.id).should be_false + end + it "deletes the unfriended user's posts from the aspect's posts" do + pending "We need to implement this" + @aspect2.posts.include?(@message).should be_false + end + end end