mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
151 - Registering with an Invalid Invitation
This commit is contained in:
@@ -12,6 +12,7 @@ class RegisterController extends Controller
|
||||
public function register()
|
||||
{
|
||||
$invitation = Invitation::findByCode(request('invitation_code'));
|
||||
abort_if($invitation->hasBeenUsed(), 404);
|
||||
|
||||
$user = User::create([
|
||||
'email' => request('email'),
|
||||
|
||||
@@ -76,4 +76,36 @@ class AcceptInvitationTest extends TestCase
|
||||
$this->assertTrue(Hash::check('secret', $user->password));
|
||||
$this->assertTrue($invitation->fresh()->user->is($user));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function registering_with_a_used_invitation_code()
|
||||
{
|
||||
$invitation = factory(Invitation::class)->create([
|
||||
'user_id' => factory(User::class)->create(),
|
||||
'code' => 'TESTCODE1234',
|
||||
]);
|
||||
$this->assertEquals(1, User::count());
|
||||
|
||||
$response = $this->post('/register', [
|
||||
'email' => 'john@example.com',
|
||||
'password' => 'secret',
|
||||
'invitation_code' => 'TESTCODE1234',
|
||||
]);
|
||||
|
||||
$response->assertStatus(404);
|
||||
$this->assertEquals(1, User::count());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function registering_with_an_invitation_code_that_does_not_exist()
|
||||
{
|
||||
$response = $this->post('/register', [
|
||||
'email' => 'john@example.com',
|
||||
'password' => 'secret',
|
||||
'invitation_code' => 'TESTCODE1234',
|
||||
]);
|
||||
|
||||
$response->assertStatus(404);
|
||||
$this->assertEquals(0, User::count());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user