mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Count resulting bulk invites correctly (#18461)
Skipped invites were not counted at all and some invites could generate more than one error and resulted in a grand total that was not equal to the count of bulk invites.
This commit is contained in:
@@ -9,7 +9,7 @@ RSpec.describe Jobs::BulkInvite do
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
let(:staged_user) { Fabricate(:user, staged: true, active: false) }
|
||||
let(:email) { 'test@discourse.org' }
|
||||
let(:invites) { [{ email: staged_user.email }, { email: 'test2@discourse.org' }, { email: 'test@discourse.org', groups: 'GROUP1;group2', topic_id: topic.id }] }
|
||||
let(:invites) { [{ email: user.email }, { email: staged_user.email }, { email: 'test2@discourse.org' }, { email: 'test@discourse.org', groups: 'GROUP1;group2', topic_id: topic.id }, { email: 'invalid' }] }
|
||||
|
||||
it 'raises an error when the invites array is missing' do
|
||||
expect { Jobs::BulkInvite.new.execute(current_user_id: user.id) }
|
||||
@@ -34,6 +34,12 @@ RSpec.describe Jobs::BulkInvite do
|
||||
expect(invite.email).to eq(email)
|
||||
expect(invite.invited_groups.pluck(:group_id)).to contain_exactly(group1.id, group2.id)
|
||||
expect(invite.topic_invites.pluck(:topic_id)).to contain_exactly(topic.id)
|
||||
|
||||
post = Post.last
|
||||
expect(post.raw).to include("3 invites")
|
||||
expect(post.raw).to include("1 skipped")
|
||||
expect(post.raw).to include("0 warning")
|
||||
expect(post.raw).to include("1 error")
|
||||
end
|
||||
|
||||
it 'does not create invited groups for automatic groups' do
|
||||
@@ -47,6 +53,9 @@ RSpec.describe Jobs::BulkInvite do
|
||||
invite = Invite.last
|
||||
expect(invite.email).to eq(email)
|
||||
expect(invite.invited_groups.pluck(:group_id)).to contain_exactly(group1.id)
|
||||
|
||||
post = Post.last
|
||||
expect(post.raw).to include("1 warning")
|
||||
end
|
||||
|
||||
it 'does not create invited groups record if the user can not manage the group' do
|
||||
|
||||
Reference in New Issue
Block a user