From 99b4f79a905182c6b0e1a339e9f4cf8364046e44 Mon Sep 17 00:00:00 2001 From: Penar Musaraj Date: Fri, 15 Nov 2019 15:11:09 -0500 Subject: [PATCH] FIX: Include 5 participants in topic summary --- app/models/topic_participants_summary.rb | 3 ++- spec/models/topic_participants_summary_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/models/topic_participants_summary.rb b/app/models/topic_participants_summary.rb index 51ecfa15cca..df3f385670f 100644 --- a/app/models/topic_participants_summary.rb +++ b/app/models/topic_participants_summary.rb @@ -3,6 +3,7 @@ # This is used on a topic page class TopicParticipantsSummary attr_reader :topic, :options + PARTICIPANT_COUNT = 5 # should match maxUserCount in topic list def initialize(topic, options = {}) @topic = topic @@ -26,7 +27,7 @@ class TopicParticipantsSummary end def top_participants - user_ids.map { |id| avatar_lookup[id] }.compact.uniq.take(4) + user_ids.map { |id| avatar_lookup[id] }.compact.uniq.take(PARTICIPANT_COUNT) end def user_ids diff --git a/spec/models/topic_participants_summary_spec.rb b/spec/models/topic_participants_summary_spec.rb index 835e22e3325..f5b3fe61905 100644 --- a/spec/models/topic_participants_summary_spec.rb +++ b/spec/models/topic_participants_summary_spec.rb @@ -21,9 +21,9 @@ describe TopicParticipantsSummary do fab!(:user4) { Fabricate(:user) } fab!(:user5) { Fabricate(:user) } - it "must never contains the user and at most 4 participants" do + it "must never contains the user and at most 5 participants" do topic.allowed_user_ids = [user1.id, user2.id, user3.id, user4.id, user5.id] - expect(summary.map(&:user)).to eq([user1, user2, user3, user4]) + expect(summary.map(&:user)).to eq([user1, user2, user3, user4, user5]) end end