1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-07 23:03:00 +03:00

Users API: Fixed sending invite when using form requests

- Cast send_invite value in cases where it might not have been a boolean,
  which occurs on non-JSON requests.
- Added test to cover.
- Updated API docs to mention and shown boolean usage.
This commit is contained in:
Dan Brown
2023-12-13 15:11:42 +00:00
parent 4896c4047f
commit 56d07f1909
3 changed files with 27 additions and 2 deletions

View File

@@ -143,6 +143,23 @@ class UsersApiTest extends TestCase
Notification::assertSentTo($user, UserInviteNotification::class);
}
public function test_create_with_send_invite_works_with_value_of_1()
{
$this->actingAsApiAdmin();
Notification::fake();
$resp = $this->postJson($this->baseEndpoint, [
'name' => 'Benny Boris',
'email' => 'bboris@example.com',
'send_invite' => '1', // Submissions via x-www-form-urlencoded/form-data may use 1 instead of boolean
]);
$resp->assertStatus(200);
/** @var User $user */
$user = User::query()->where('email', '=', 'bboris@example.com')->first();
Notification::assertSentTo($user, UserInviteNotification::class);
}
public function test_create_name_and_email_validation()
{
$this->actingAsApiAdmin();