FIX: Include 5 participants in topic summary

This commit is contained in:
Penar Musaraj 2019-11-15 15:11:09 -05:00
parent 4cf3c9cccb
commit 99b4f79a90
2 changed files with 4 additions and 3 deletions

View File

@ -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

View File

@ -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