mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 11:32:46 +08:00
FIX: on topic page, don't try to render post counts for a deleted user
This commit is contained in:
parent
dc801bb442
commit
4a11bb5227
|
@ -212,6 +212,7 @@ class TopicView
|
||||||
|
|
||||||
def post_counts_by_user
|
def post_counts_by_user
|
||||||
@post_counts_by_user ||= Post.where(topic_id: @topic.id)
|
@post_counts_by_user ||= Post.where(topic_id: @topic.id)
|
||||||
|
.where("user_id IS NOT NULL")
|
||||||
.group(:user_id)
|
.group(:user_id)
|
||||||
.order("count_all DESC")
|
.order("count_all DESC")
|
||||||
.limit(24)
|
.limit(24)
|
||||||
|
|
|
@ -158,6 +158,12 @@ describe TopicView do
|
||||||
it 'returns the two posters with their counts' do
|
it 'returns the two posters with their counts' do
|
||||||
expect(topic_view.post_counts_by_user.to_a).to match_array([[first_poster.id, 2], [coding_horror.id, 1]])
|
expect(topic_view.post_counts_by_user.to_a).to match_array([[first_poster.id, 2], [coding_horror.id, 1]])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't return counts for posts with authors who have been deleted" do
|
||||||
|
p2.user_id = nil
|
||||||
|
p2.save!
|
||||||
|
expect(topic_view.post_counts_by_user.to_a).to match_array([[first_poster.id, 2]])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context '.participants' do
|
context '.participants' do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user