From bd930a9c77919ced40d593063bf7672b0d1bb29e Mon Sep 17 00:00:00 2001 From: romanrizzi Date: Tue, 10 Sep 2019 14:21:34 -0300 Subject: [PATCH] FIX: Do not show staged users avatars when expanding the read count indicator --- app/controllers/post_readers_controller.rb | 1 + spec/requests/post_readers_controller_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+) 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)