diff --git a/lib/diaspora/user/friending.rb b/lib/diaspora/user/friending.rb index a37a64e1b..af577acdf 100644 --- a/lib/diaspora/user/friending.rb +++ b/lib/diaspora/user/friending.rb @@ -95,8 +95,8 @@ module Diaspora raise "Friend not deleted" unless self.friend_ids.delete(contact.id) contact.aspects.each{|aspect| contact.aspects.delete(aspect) - aspect.posts.delete_if { |post| - post.person_id == bad_friend.id + aspect.posts.each { |post| + aspect.post_ids.delete(post.id) if post.person == bad_friend } aspect.save } diff --git a/spec/models/user/friending_spec.rb b/spec/models/user/friending_spec.rb index b8d8d33d7..aefcc09c8 100644 --- a/spec/models/user/friending_spec.rb +++ b/spec/models/user/friending_spec.rb @@ -238,13 +238,20 @@ describe Diaspora::UserModules::Friending do context 'with a post' do before do @message = user.post(:status_message, :message => "hi", :to => aspect.id) - user2.unfriend user.person end + it "deletes the unfriended user's posts from visible_posts" do - user.reload.raw_visible_posts.include?(@message.id).should be_false + user2.reload.raw_visible_posts.include?(@message).should be_true + user2.unfriend user.person + user2.reload.raw_visible_posts.include?(@message).should be_false end + it "deletes the unfriended user's posts from the aspect's posts" do - aspect2.posts.include?(@message).should be_false + Post.count.should == 1 + aspect2.reload.posts.include?(@message).should be_true + user2.unfriend user.person + aspect2.reload.posts.include?(@message).should be_false + Post.count.should == 1 end end end