FIX: do not add invited user to automatic groups

This commit is contained in:
Arpit Jalan 2018-05-28 15:51:08 +05:30
parent 81b5d61fa7
commit c8bc942333
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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