mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 11:13:38 +08:00
c9dab6fd08
It's very easy to forget to add `require 'rails_helper'` at the top of every core/plugin spec file, and omissions can cause some very confusing/sporadic errors. By setting this flag in `.rspec`, we can remove the need for `require 'rails_helper'` entirely.
28 lines
1.0 KiB
Ruby
28 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe TopicViewDetailsSerializer do
|
|
describe '#allowed_users' do
|
|
it "add the current user to the allowed user's list even if they are an allowed group member" do
|
|
participant = Fabricate(:user)
|
|
another_participant = Fabricate(:user)
|
|
|
|
participant_group = Fabricate(:group)
|
|
participant_group.add(participant)
|
|
participant_group.add(another_participant)
|
|
|
|
pm = Fabricate(:private_message_topic,
|
|
topic_allowed_users: [
|
|
Fabricate.build(:topic_allowed_user, user: participant),
|
|
Fabricate.build(:topic_allowed_user, user: another_participant)
|
|
],
|
|
topic_allowed_groups: [Fabricate.build(:topic_allowed_group, group: participant_group)]
|
|
)
|
|
|
|
serializer = described_class.new(TopicView.new(pm, participant), scope: Guardian.new(participant))
|
|
allowed_users = serializer.as_json.dig(:topic_view_details, :allowed_users).map { |u| u[:id] }
|
|
|
|
expect(allowed_users).to contain_exactly(participant.id)
|
|
end
|
|
end
|
|
end
|