refactor(role): remove transactions and tidy up logic in model (#2141)
* refactor(role): remove returning this in model methods * refactor(role): assert altering admin in model before update and delete * refactor(role): rename overridePermissions with updatePermissions in model * refactor(role): remove transactions in model * refactor(role): remove transactions in model * refactor(role): return with permissions upon update in model * fix(role): assert admin check on old instance in model * refactor(role): fetch and use current role in preventAlteringAdmin
This commit is contained in:
@@ -92,21 +92,4 @@ describe('DELETE /api/v1/admin/roles/:roleId', () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should not delete role and permissions on unsuccessful response', async () => {
|
||||
const role = await createRole();
|
||||
const permission = await createPermission({ roleId: role.id });
|
||||
await createUser({ roleId: role.id });
|
||||
|
||||
await request(app)
|
||||
.delete(`/api/v1/admin/roles/${role.id}`)
|
||||
.set('Authorization', token)
|
||||
.expect(422);
|
||||
|
||||
const refetchedRole = await role.$query();
|
||||
const refetchedPermission = await permission.$query();
|
||||
|
||||
expect(refetchedRole).toStrictEqual(role);
|
||||
expect(refetchedPermission).toStrictEqual(permission);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user