mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 07:19:40 +08:00
FIX: delete duplicate invites
This commit is contained in:
@ -188,6 +188,18 @@ describe Invite do
|
||||
expect(invite.redeem).to be_blank
|
||||
end
|
||||
|
||||
context "deletes duplicate invites" do
|
||||
let(:another_user) { Fabricate(:user) }
|
||||
|
||||
it 'delete duplicate invite' do
|
||||
another_invite = Fabricate(:invite, email: invite.email, invited_by: another_user)
|
||||
invite.redeem
|
||||
duplicate_invite = Invite.find_by(id: another_invite.id)
|
||||
expect(duplicate_invite).to be_nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'enqueues a job to email "set password" instructions' do
|
||||
|
||||
it 'does not enqueue an email if sso is enabled' do
|
||||
@ -329,17 +341,14 @@ describe Invite do
|
||||
it 'adds the user to the topic_users of the first topic' do
|
||||
expect(topic.allowed_users.include?(user)).to eq(true)
|
||||
expect(another_topic.allowed_users.include?(user)).to eq(true)
|
||||
another_invite.reload
|
||||
expect(another_invite).not_to be_redeemed
|
||||
duplicate_invite = Invite.find_by(id: another_invite.id)
|
||||
expect(duplicate_invite).to be_nil
|
||||
end
|
||||
|
||||
context 'if they redeem the other invite afterwards' do
|
||||
|
||||
it 'returns the same user' do
|
||||
result = another_invite.redeem
|
||||
expect(result).to eq(user)
|
||||
another_invite.reload
|
||||
expect(another_invite).to be_redeemed
|
||||
it 'wont redeem a duplicate invite' do
|
||||
expect(another_invite.redeem).to be_blank
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user