FIX: Skip whisper posts when updating topic like count (#10157)

This commit is contained in:
Bianca Nenciu
2020-07-13 09:30:00 +03:00
committed by GitHub
parent 54d002f7db
commit 4492718864
3 changed files with 52 additions and 1 deletions

View File

@@ -2634,4 +2634,26 @@ describe Topic do
expect(@topic.auto_close_threshold_reached?).to eq(true)
end
end
describe '#update_action_counts' do
let(:topic) { Fabricate(:topic) }
it 'updates like count without including whisper posts' do
post = Fabricate(:post, topic: topic)
whisper_post = Fabricate(:post, topic: topic, post_type: Post.types[:whisper])
topic.update_action_counts
expect(topic.like_count).to eq(0)
PostAction.create!(post: post, user: user, post_action_type_id: PostActionType.types[:like])
topic.update_action_counts
expect(topic.like_count).to eq(1)
PostAction.create!(post: whisper_post, user: user, post_action_type_id: PostActionType.types[:like])
topic.update_action_counts
expect(topic.like_count).to eq(1)
end
end
end