mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 03:16:41 +08:00
FIX: Only serialize group membership domains for administrators (#6771)
This commit is contained in:
parent
a19f69590a
commit
9f3e2a9e34
|
@ -42,6 +42,14 @@ class BasicGroupSerializer < ApplicationSerializer
|
|||
staff?
|
||||
end
|
||||
|
||||
def include_automatic_membership_email_domains?
|
||||
scope.is_admin?
|
||||
end
|
||||
|
||||
def include_automatic_membership_retroactive?
|
||||
scope.is_admin?
|
||||
end
|
||||
|
||||
def include_has_messages?
|
||||
staff? || scope.can_see_group_messages?(object)
|
||||
end
|
||||
|
|
|
@ -43,6 +43,24 @@ describe BasicGroupSerializer do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#automatic_membership_email_domains' do
|
||||
let(:group) { Fabricate(:group, automatic_membership_email_domains: 'ilovediscourse.com', automatic_membership_retroactive: true) }
|
||||
let(:admin_guardian) { Guardian.new(Fabricate(:admin)) }
|
||||
|
||||
it 'should include email domains for admin' do
|
||||
subject = described_class.new(group, scope: admin_guardian, root: false, owner_group_ids: [group.id])
|
||||
expect(subject.as_json[:automatic_membership_email_domains]).to eq('ilovediscourse.com')
|
||||
expect(subject.as_json[:automatic_membership_retroactive]).to eq(true)
|
||||
end
|
||||
|
||||
it 'should not include email domains for other users' do
|
||||
subject = described_class.new(group, scope: guardian, root: false, owner_group_ids: [group.id])
|
||||
expect(subject.as_json[:automatic_membership_email_domains]).to eq(nil)
|
||||
expect(subject.as_json[:automatic_membership_retroactive]).to eq(nil)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe '#has_messages' do
|
||||
let(:group) { Fabricate(:group, has_messages: true) }
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user