mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Tightened up tests with better checks
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
ea8d390596
commit
67fb3f10d5
|
@ -370,10 +370,10 @@ class UsersController extends Controller
|
|||
->with('error', trans_choice('admin/users/message.error.delete_has_locations_var', $user->managedLocations()->count(), ['count'=> $user->managedLocations()->count()]));
|
||||
}
|
||||
|
||||
// if (($user->managesUsers()) && ($user->managesUsers()->count() > 0)) {
|
||||
// return redirect()->route('users.index')
|
||||
// ->with('error', trans_choice('admin/users/message.error.delete_has_users_var', $user->managesUsers()->count(), ['count'=> $user->managesUsers()->count()]));
|
||||
// }
|
||||
if (($user->managesUsers()) && ($user->managesUsers()->count() > 0)) {
|
||||
return redirect()->route('users.index')
|
||||
->with('error', trans_choice('admin/users/message.error.delete_has_users_var', $user->managesUsers()->count(), ['count'=> $user->managesUsers()->count()]));
|
||||
}
|
||||
|
||||
// Delete the user
|
||||
$user->delete();
|
||||
|
|
|
@ -18,10 +18,12 @@ class DeleteUsersTest extends TestCase
|
|||
|
||||
$this->actingAs(User::factory()->deleteUsers()->create())->assertFalse($manager->isDeletable());
|
||||
|
||||
$this->actingAs(User::factory()->deleteUsers()->create())
|
||||
$response = $this->actingAs(User::factory()->deleteUsers()->viewUsers()->create())
|
||||
->delete(route('users.destroy', $manager->id))
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('users.index'));
|
||||
|
||||
$this->followRedirects($response)->assertSee('Error');
|
||||
}
|
||||
|
||||
public function testDisallowUserDeletionIfStillManagingLocations()
|
||||
|
@ -31,10 +33,12 @@ class DeleteUsersTest extends TestCase
|
|||
|
||||
$this->actingAs(User::factory()->deleteUsers()->create())->assertFalse($manager->isDeletable());
|
||||
|
||||
$this->actingAs(User::factory()->deleteUsers()->create())
|
||||
$response = $this->actingAs(User::factory()->deleteUsers()->viewUsers()->create())
|
||||
->delete(route('users.destroy', $manager->id))
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('users.index'));
|
||||
|
||||
$this->followRedirects($response)->assertSee('Error');
|
||||
}
|
||||
|
||||
public function testAllowUserDeletionIfNotManagingLocations()
|
||||
|
@ -42,10 +46,13 @@ class DeleteUsersTest extends TestCase
|
|||
$manager = User::factory()->create();
|
||||
$this->actingAs(User::factory()->deleteUsers()->create())->assertTrue($manager->isDeletable());
|
||||
|
||||
$this->actingAs(User::factory()->deleteUsers()->create())
|
||||
$response = $this->actingAs(User::factory()->deleteUsers()->viewUsers()->create())
|
||||
->delete(route('users.destroy', $manager->id))
|
||||
->assertStatus(302)
|
||||
->assertRedirect(route('users.index'));
|
||||
|
||||
$this->followRedirects($response)->assertSee('Success');
|
||||
|
||||
}
|
||||
|
||||
public function testDisallowUserDeletionIfNoDeletePermissions()
|
||||
|
|
Loading…
Reference in a new issue