diff --git a/app/models/reshare.rb b/app/models/reshare.rb index d69c9d278143fbf95d8b2f08c922a39da968bb3e..bb914d40146ee966423bae6f9887fa5a37db3145 100644 --- a/app/models/reshare.rb +++ b/app/models/reshare.rb @@ -70,7 +70,7 @@ class Reshare < Post end def subscribers - super + [root.author] + super.tap {|people| root.try {|root| people << root.author } } end private diff --git a/spec/models/reshare_spec.rb b/spec/models/reshare_spec.rb index 208a62d7a32d86fdd10937c1bb0cd879a2480e05..cc436de9aad92483880db3cdd71e8c984c766311 100644 --- a/spec/models/reshare_spec.rb +++ b/spec/models/reshare_spec.rb @@ -135,5 +135,16 @@ describe Reshare, type: :model do expect(reshare.subscribers).to match_array([alice.person, eve.person, user.person]) end + + it "does not add the root author if the root post was deleted" do + user = FactoryGirl.create(:user_with_aspect) + user.share_with(alice.person, user.aspects.first) + + post = eve.post(:status_message, text: "hello", public: true) + reshare = FactoryGirl.create(:reshare, root: post, author: user.person) + post.destroy + + expect(reshare.reload.subscribers).to match_array([alice.person, user.person]) + end end end