diff --git a/app/models/reshare.rb b/app/models/reshare.rb index d69c9d278..bb914d401 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 208a62d7a..cc436de9a 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