mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-14 11:12:16 +01:00
Added invitation delete endpoint
This commit is contained in:
committed by
Constantin Graf
parent
ad6146c483
commit
a149db655c
@@ -76,4 +76,52 @@ class InvitationEndpointTest extends ApiEndpointTestAbstract
|
||||
$this->assertEquals('test@asdf.at', $invitation->email);
|
||||
$this->assertEquals('employee', $invitation->role);
|
||||
}
|
||||
|
||||
public function test_delete_fails_if_user_has_no_permission_to_remove_invitations(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
]);
|
||||
Passport::actingAs($data->user);
|
||||
$invitation = OrganizationInvitation::factory()->forOrganization($data->organization)->create();
|
||||
|
||||
// Act
|
||||
$response = $this->deleteJson(route('api.v1.invitations.destroy', [$data->organization->getKey(), $invitation->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
}
|
||||
|
||||
public function test_delete_fails_if_invitation_belongs_to_different_organization(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
'invitations:remove',
|
||||
]);
|
||||
Passport::actingAs($data->user);
|
||||
$invitation = OrganizationInvitation::factory()->create();
|
||||
|
||||
// Act
|
||||
$response = $this->deleteJson(route('api.v1.invitations.destroy', [$data->organization->getKey(), $invitation->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(403);
|
||||
}
|
||||
|
||||
public function test_delete_removes_invitation(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
'invitations:remove',
|
||||
]);
|
||||
Passport::actingAs($data->user);
|
||||
$invitation = OrganizationInvitation::factory()->forOrganization($data->organization)->create();
|
||||
|
||||
// Act
|
||||
$response = $this->deleteJson(route('api.v1.invitations.destroy', [$data->organization->getKey(), $invitation->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(204);
|
||||
$this->assertNull(OrganizationInvitation::find($invitation->getKey()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user