Skip to content

A platform for community discussion. Free, open, simple.

FIX: Do not show staged users avatars when expanding the read count indicator

romanrizzibd930a9c7791
diff --git a/app/controllers/post_readers_controller.rb b/app/controllers/post_readers_controller.rb
index 392f575c9b0..e70d49b2165 100644
--- a/app/controllers/post_readers_controller.rb
+++ b/app/controllers/post_readers_controller.rb
@@ -10,6 +10,7 @@ class PostReadersController < ApplicationController
readers = User
.joins(:topic_users)
+ .where(staged: false)
.where.not(topic_users: { last_read_post_number: nil })
.where('topic_users.topic_id = ? AND topic_users.last_read_post_number >= ?', post.topic_id, post.post_number)
.where.not(id: post.user_id)
diff --git a/spec/requests/post_readers_controller_spec.rb b/spec/requests/post_readers_controller_spec.rb
index 267dfea1100..954e14b6f33 100644
--- a/spec/requests/post_readers_controller_spec.rb
+++ b/spec/requests/post_readers_controller_spec.rb
@@ -66,6 +66,16 @@ describe PostReadersController do
expect(readers).to be_empty
end
+
+ it "doesn't include staged users" do
+ TopicUser.create!(user: reader, topic: @group_message, last_read_post_number: 4)
+ reader.update(staged: true)
+
+ 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)