feat: accept terms
This commit is contained in:
@@ -27,6 +27,7 @@ it('sends a verification email when a user registers', function () {
|
||||
'pacePreference' => PacePreference::NORMAL->value,
|
||||
'sex' => UserSex::WOMAN->value,
|
||||
'dateOfBirth' => '2003-04-24',
|
||||
'termsAccepted' => true,
|
||||
])
|
||||
->assertCreated()
|
||||
->assertJsonPath('user.email', 'leon@example.com')
|
||||
@@ -45,7 +46,8 @@ it('sends a verification email when a user registers', function () {
|
||||
|
||||
expect($user->hasVerifiedEmail())->toBeFalse()
|
||||
->and($user->trial_ends_at)->not->toBeNull()
|
||||
->and($user->trial_ends_at->isFuture())->toBeTrue();
|
||||
->and($user->trial_ends_at->isFuture())->toBeTrue()
|
||||
->and($user->terms_accepted_at)->not->toBeNull();
|
||||
|
||||
$this->assertDatabaseHas('users', [
|
||||
'id' => $user->id,
|
||||
@@ -71,6 +73,7 @@ it('returns a temporary error when the verification email cannot be sent during
|
||||
'email' => 'leon@example.com',
|
||||
'password' => 'Motsdfdepasse123*',
|
||||
'locale' => 'fr-FR',
|
||||
'termsAccepted' => true,
|
||||
])
|
||||
->assertServiceUnavailable()
|
||||
->assertJsonPath('message', __('api.auth.verification_email_failed'));
|
||||
@@ -94,6 +97,7 @@ it('registers mobile users with a bearer token', function () {
|
||||
'pacePreference' => PacePreference::NORMAL->value,
|
||||
'sex' => UserSex::MAN->value,
|
||||
'dateOfBirth' => '2003-04-24',
|
||||
'termsAccepted' => true,
|
||||
])
|
||||
->assertCreated()
|
||||
->assertJsonPath('user.email', 'mobile.leon@example.com')
|
||||
@@ -111,6 +115,31 @@ it('registers mobile users with a bearer token', function () {
|
||||
Notification::assertSentTo($user, VerifyEmail::class);
|
||||
});
|
||||
|
||||
it('requires users to accept the terms during registration', function () {
|
||||
Notification::fake();
|
||||
|
||||
$registrationData = [
|
||||
'name' => 'TermsLeon',
|
||||
'email' => 'terms.leon@example.com',
|
||||
'password' => 'Motsdfdepasse123*',
|
||||
'termsAccepted' => false,
|
||||
];
|
||||
|
||||
$this->postJson('/api/auth/mobile/register', $registrationData)
|
||||
->assertUnprocessable()
|
||||
->assertJsonValidationErrors('termsAccepted');
|
||||
|
||||
unset($registrationData['termsAccepted']);
|
||||
|
||||
$this->postJson('/api/auth/mobile/register', $registrationData)
|
||||
->assertUnprocessable()
|
||||
->assertJsonValidationErrors('termsAccepted');
|
||||
|
||||
$this->assertDatabaseMissing('users', [
|
||||
'email' => 'terms.leon@example.com',
|
||||
]);
|
||||
});
|
||||
|
||||
it('uses the custom account verification mailable', function () {
|
||||
$user = User::factory()->unverified()->create([
|
||||
'locale' => 'fr',
|
||||
|
||||
Reference in New Issue
Block a user