Merge pull request #7005 from SuperTux88/fix-reshare-delete
don't add the root author to the subscribers if the root post was deleted
This commit is contained in:
commit
08c6d485e4
2 changed files with 12 additions and 1 deletions
|
|
@ -70,7 +70,7 @@ class Reshare < Post
|
||||||
end
|
end
|
||||||
|
|
||||||
def subscribers
|
def subscribers
|
||||||
super + [root.author]
|
super.tap {|people| root.try {|root| people << root.author } }
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
||||||
|
|
@ -135,5 +135,16 @@ describe Reshare, type: :model do
|
||||||
|
|
||||||
expect(reshare.subscribers).to match_array([alice.person, eve.person, user.person])
|
expect(reshare.subscribers).to match_array([alice.person, eve.person, user.person])
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue