FIX: Show read indicator only for group PMs (#11224)

It used to show for PMs converted to public topics.
This commit is contained in:
Bianca Nenciu 2020-11-13 19:13:37 +02:00 committed by GitHub
parent 65e123498b
commit 5ca0fbc423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 1 deletions

View File

@ -106,7 +106,7 @@ class TopicView
end
def 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)

View File

@ -795,4 +795,30 @@ describe TopicView do
end
end
end
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
end
end