2019-04-30 08:27:42 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-28 10:27:38 +08:00
|
|
|
RSpec.describe TopicParticipantsSummary do
|
2014-05-12 15:32:49 +08:00
|
|
|
describe "#summary" do
|
|
|
|
let(:summary) { described_class.new(topic, user: topic_creator).summary }
|
|
|
|
|
|
|
|
let(:topic) do
|
2014-09-11 15:39:20 +08:00
|
|
|
Fabricate(:topic, user: topic_creator, archetype: Archetype.private_message, category_id: nil)
|
2014-05-12 15:32:49 +08:00
|
|
|
end
|
|
|
|
|
2019-05-07 11:12:20 +08: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) }
|
2019-11-18 22:43:14 +08:00
|
|
|
fab!(:user6) { Fabricate(:user) }
|
2014-05-12 15:32:49 +08:00
|
|
|
|
2019-11-16 04:11:09 +08:00
|
|
|
it "must never contains the user and at most 5 participants" do
|
2019-11-18 22:43:14 +08:00
|
|
|
topic.allowed_user_ids = [user1.id, user2.id, user3.id, user4.id, user5.id, user6.id]
|
2019-11-16 04:11:09 +08:00
|
|
|
expect(summary.map(&:user)).to eq([user1, user2, user3, user4, user5])
|
2014-05-12 15:32:49 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|