mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
parent
3410cf21cb
commit
0a0fdd7f3e
@ -151,7 +151,8 @@ class RoleController extends Controller
|
||||
$this->checkPermission('user-roles-manage');
|
||||
|
||||
try {
|
||||
$this->permissionsRepo->deleteRole($id, $request->get('migrate_role_id', 0));
|
||||
$migrateRoleId = intval($request->get('migrate_role_id') ?: "0");
|
||||
$this->permissionsRepo->deleteRole($id, $migrateRoleId);
|
||||
} catch (PermissionsException $e) {
|
||||
$this->showErrorNotification($e->getMessage());
|
||||
|
||||
|
@ -163,6 +163,22 @@ class RolesTest extends TestCase
|
||||
$this->assertEquals($this->user->id, $roleA->users()->first()->id);
|
||||
}
|
||||
|
||||
public function test_delete_with_empty_migrate_option_works()
|
||||
{
|
||||
$role = $this->users->attachNewRole($this->user);
|
||||
|
||||
$this->assertCount(1, $role->users()->get());
|
||||
|
||||
$deletePage = $this->asAdmin()->get("/settings/roles/delete/$role->id");
|
||||
$this->withHtml($deletePage)->assertElementExists('select[name=migrate_role_id]');
|
||||
$resp = $this->asAdmin()->delete("/settings/roles/delete/$role->id", [
|
||||
'migrate_role_id' => '',
|
||||
]);
|
||||
|
||||
$resp->assertRedirect('/settings/roles');
|
||||
$this->assertDatabaseMissing('roles', ['id' => $role->id]);
|
||||
}
|
||||
|
||||
public function test_entity_permissions_are_removed_on_delete()
|
||||
{
|
||||
/** @var Role $roleA */
|
||||
|
Loading…
Reference in New Issue
Block a user