FIX: Do not increase invite count for current user (#15952)

The current user could redeem an invite created by themselves.
This commit is contained in:
Dan Ungureanu
2022-02-15 17:35:58 +02:00
committed by GitHub
parent d83da596be
commit dd5373cc4c
2 changed files with 21 additions and 9 deletions

View File

@ -117,6 +117,16 @@ describe InvitesController do
expect(Notification.where(user: invite.invited_by, notification_type: Notification.types[:invitee_accepted]).count).to eq(1)
end
it 'creates an invited user record' do
sign_in(invite.invited_by)
expect { get "/invites/#{invite.invite_key}" }.to change { InvitedUser.count }.by(0)
expect(response.status).to eq(302)
sign_in(user)
expect { get "/invites/#{invite.invite_key}" }.to change { InvitedUser.count }.by(1)
expect(response.status).to eq(302)
end
it 'fails if invite does not exist' do
get '/invites/missing'
expect(response.status).to eq(200)