mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
FIX: do not delete already redeemed invite
This commit is contained in:
parent
90de61ee3d
commit
fb0e7dc0b2
2 changed files with 8 additions and 1 deletions
|
@ -117,6 +117,6 @@ InviteRedeemer = Struct.new(:invite, :username, :name) do
|
|||
end
|
||||
|
||||
def delete_duplicate_invites
|
||||
Invite.where('invites.email = ? and invites.id != ?', invite.email, invite.id).delete_all
|
||||
Invite.where('invites.email = ? AND redeemed_at IS NULL AND invites.id != ?', invite.email, invite.id).delete_all
|
||||
end
|
||||
end
|
||||
|
|
|
@ -198,6 +198,13 @@ describe Invite do
|
|||
expect(duplicate_invite).to be_nil
|
||||
end
|
||||
|
||||
it 'does not delete already redeemed invite' do
|
||||
redeemed_invite = Fabricate(:invite, email: invite.email, invited_by: another_user, redeemed_at: 1.day.ago)
|
||||
invite.redeem
|
||||
used_invite = Invite.find_by(id: redeemed_invite.id)
|
||||
expect(used_invite).not_to be_nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'enqueues a job to email "set password" instructions' do
|
||||
|
|
Loading…
Reference in a new issue