FIX: do not add invited user to automatic groups
This commit is contained in:
parent
81b5d61fa7
commit
c8bc942333
|
@ -139,7 +139,7 @@ class Invite < ActiveRecord::Base
|
|||
end
|
||||
else
|
||||
if topic && topic.category && Guardian.new(invited_by).can_invite_to?(topic)
|
||||
group_ids = topic.category.groups.pluck(:id) - invite.invited_groups.pluck(:group_id)
|
||||
group_ids = topic.category.groups.pluck(:id) - invite.invited_groups.pluck(:group_id) - Group.where(automatic: true).pluck(:id)
|
||||
group_ids.each { |group_id| invite.invited_groups.create!(group_id: group_id) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -162,6 +162,13 @@ describe Invite do
|
|||
invite = group_private_topic.invite_by_email(tl2_user, 'foo@bar.com')
|
||||
expect(invite.groups.count).to eq(0)
|
||||
end
|
||||
|
||||
context 'automatic groups' do
|
||||
it 'should not add invited user to automatic groups' do
|
||||
group.update!(automatic: true)
|
||||
expect(group_private_topic.invite_by_email(Fabricate(:admin), iceking).groups.count).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'an existing user' do
|
||||
|
|
Loading…
Reference in New Issue