mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
Restrict removing owner from organization
This commit is contained in:
@@ -141,6 +141,23 @@ class MemberEndpointTest extends ApiEndpointTestAbstract
|
||||
$response->assertStatus(403);
|
||||
}
|
||||
|
||||
public function test_destroy_member_fails_if_member_is_owner(): void
|
||||
{
|
||||
// Arrange
|
||||
$data = $this->createUserWithPermission([
|
||||
'members:delete',
|
||||
]);
|
||||
$memberToDelete = Member::factory()->forOrganization($data->organization)->role(Role::Owner)->create();
|
||||
Passport::actingAs($data->user);
|
||||
|
||||
// Act
|
||||
$response = $this->deleteJson(route('api.v1.members.destroy', [$data->organization->getKey(), $memberToDelete->getKey()]));
|
||||
|
||||
// Assert
|
||||
$response->assertStatus(400);
|
||||
$response->assertJsonPath('message', 'Can not remove owner from organization');
|
||||
}
|
||||
|
||||
public function test_destroy_member_fails_if_member_is_not_part_of_org(): void
|
||||
{
|
||||
// Arrange
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Tests\Unit\Service\Import;
|
||||
use App\Models\Organization;
|
||||
use App\Service\Import\ImportService;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ImportServiceTest extends TestCase
|
||||
@@ -16,6 +17,7 @@ class ImportServiceTest extends TestCase
|
||||
public function test_import_gets_importer_from_provider_runs_importer_and_returns_report(): void
|
||||
{
|
||||
// Arrange
|
||||
Storage::fake('s3');
|
||||
$organization = Organization::factory()->create();
|
||||
$data = file_get_contents(storage_path('tests/toggl_time_entries_import_test_1.csv'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user