2019-04-29 20:27:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-10-11 05:41:23 -04:00
|
|
|
require 'rails_helper'
|
2014-05-12 03:32:49 -04:00
|
|
|
|
|
|
|
describe TopicParticipantsSummary do
|
|
|
|
describe '#summary' do
|
|
|
|
let(:summary) { described_class.new(topic, user: topic_creator).summary }
|
|
|
|
|
|
|
|
let(:topic) do
|
|
|
|
Fabricate(:topic,
|
|
|
|
user: topic_creator,
|
2014-09-11 03:39:20 -04:00
|
|
|
archetype: Archetype::private_message,
|
|
|
|
category_id: nil
|
2014-05-12 03:32:49 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2019-05-06 23:12:20 -04:00
|
|
|
fab!(:topic_creator) { Fabricate(:user) }
|
|
|
|
fab!(:user1) { Fabricate(:user) }
|
|
|
|
fab!(:user2) { Fabricate(:user) }
|
|
|
|
fab!(:user3) { Fabricate(:user) }
|
|
|
|
fab!(:user4) { Fabricate(:user) }
|
|
|
|
fab!(:user5) { Fabricate(:user) }
|
2014-05-12 03:32:49 -04:00
|
|
|
|
2019-01-25 09:11:49 -05:00
|
|
|
it "must never contains the user and at most 4 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])
|
2014-05-12 03:32:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|