mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Skip whisper posts when updating topic like count (#10157)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user