Remove like on change of ownership. (#5038)

This commit is contained in:
Bianca Nenciu 2017-08-11 08:55:00 +01:00 committed by Régis Hanol
parent f2539a86d0
commit 117417848e
2 changed files with 5 additions and 0 deletions

View File

@ -22,6 +22,7 @@ class PostOwnerChanger
end
post.topic = @topic
post.set_owner(@new_owner, @acting_user, @skip_revision)
PostAction.remove_act(@new_owner, post, PostActionType.types[:like])
end
@topic.update_statistics

View File

@ -26,8 +26,12 @@ describe PostOwnerChanger do
freeze_time 2.days.from_now
old_user = p1.user
PostAction.act(user_a, p1, PostActionType.types[:like])
p1.reload
expect(p1.topic.like_count).to eq(1)
PostOwnerChanger.new(post_ids: [p1.id], topic_id: topic.id, new_owner: user_a, acting_user: editor).change_owner!
p1.reload
expect(p1.topic.like_count).to eq(0)
expect(p1.topic.bumped_at).to be_within(1.second).of (bumped_at)
expect(p1.topic.last_post_user_id).to eq(user_a.id)
expect(old_user).not_to eq(p1.user)