FIX: Don't show bots as post readers

This commit is contained in:
romanrizzi 2019-11-14 17:53:52 -03:00
parent f87d38fc7c
commit ff355ad204
2 changed files with 10 additions and 0 deletions

View File

@ -8,6 +8,7 @@ class PostReadersController < ApplicationController
ensure_can_see_readers!(post)
readers = User
.real
.where(staged: false)
.where.not(id: post.user_id)
.joins(:topic_users)

View File

@ -88,6 +88,15 @@ describe PostReadersController do
expect(readers).to be_empty
end
it "doesn't include bots" do
TopicUser.create!(user: Discourse.system_user, topic: @group_message, last_read_post_number: 4)
get '/post_readers.json', params: { id: @post.id }
readers = JSON.parse(response.body)['post_readers']
expect(readers).to be_empty
end
end
def assert_reader_is_correctly_serialized(reader_data, reader, post)