A platform for community discussion. Free, open, simple.
FIX: Show read indicator only for group PMs (#11224)
Bianca Nenciu5ca0fbc42374
diff --git a/lib/topic_view.rb b/lib/topic_view.rbindex 8d985757ceb..d02d4028b16 100644--- a/lib/topic_view.rb+++ b/lib/topic_view.rb@@ -106,7 +106,7 @@ class TopicViewenddef show_read_indicator?- return false unless @user || topic.private_message?+ return false if !@user || !topic.private_message?topic.allowed_groups.any? do |group|group.publish_read_state? && group.users.include?(@user)diff --git a/spec/components/topic_view_spec.rb b/spec/components/topic_view_spec.rbindex e6a1c0f1840..e3a159ded3a 100644--- a/spec/components/topic_view_spec.rb+++ b/spec/components/topic_view_spec.rb@@ -795,4 +795,30 @@ describe TopicView doendendend++ describe '#show_read_indicator?' do+ let(:topic) { Fabricate(:topic) }+ let(:pm_topic) { Fabricate(:private_message_topic) }++ it "shows read indicator for private messages" do+ group = Fabricate(:group, users: [admin], publish_read_state: true)+ pm_topic.topic_allowed_groups = [Fabricate.build(:topic_allowed_group, group: group)]++ topic_view = TopicView.new(pm_topic.id, admin)+ expect(topic_view.show_read_indicator?).to be_truthy+ end++ it "does not show read indicator if groups do not have read indicator enabled" do+ topic_view = TopicView.new(pm_topic.id, admin)+ expect(topic_view.show_read_indicator?).to be_falsey+ end++ it "does not show read indicator for topics with allowed groups" do+ group = Fabricate(:group, users: [admin], publish_read_state: true)+ topic.topic_allowed_groups = [Fabricate.build(:topic_allowed_group, group: group)]++ topic_view = TopicView.new(topic.id, admin)+ expect(topic_view.show_read_indicator?).to be_falsey+ end+ endend