mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Added test if user has assets
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
c5cbe37007
commit
374c6845d6
|
@ -2,11 +2,13 @@
|
|||
|
||||
namespace Tests\Feature\Users\Ui;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Models\LicenseSeat;
|
||||
use App\Models\Location;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
use App\Models\Asset;
|
||||
|
||||
class DeleteUserTest extends TestCase
|
||||
{
|
||||
|
@ -94,6 +96,22 @@ class DeleteUserTest extends TestCase
|
|||
$this->actingAs(User::factory()->editUsers()->viewUsers()->create())->assertFalse($manager->isDeletable());
|
||||
}
|
||||
|
||||
public function testDisallowUserDeletionIfTheyStillHaveAssets()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
Asset::factory()->count(6)->checkedOutToUser($user)->create();
|
||||
|
||||
$this->actingAs(User::factory()->deleteUsers()->viewUsers()->create())->assertFalse($user->isDeletable());
|
||||
|
||||
$response = $this->actingAs(User::factory()->deleteUsers()->viewUsers()->create())
|
||||
->delete(route('users.destroy', $user->id))
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('users.index'));
|
||||
|
||||
$this->followRedirects($response)->assertSee('Error');
|
||||
}
|
||||
|
||||
|
||||
public function testUsersCannotDeleteThemselves()
|
||||
{
|
||||
$manager = User::factory()->deleteUsers()->viewUsers()->create();
|
||||
|
|
Loading…
Reference in a new issue