WIP Roles and permissions access control.

This commit is contained in:
Ahmed Bouhuolia
2019-09-11 21:40:09 +02:00
parent 9a8de9ca7d
commit cba17739d6
24 changed files with 847 additions and 20 deletions

View File

@@ -0,0 +1,15 @@
import { create, expect } from '~/testInit';
import User from '@/models/User';
import '@/models/Role';
describe('Model: User', () => {
it('User model may has many associated roles.', async () => {
const userHasRole = await create('user_has_role');
await create('user_has_role', { user_id: userHasRole.user_id });
const userModel = await User.where('id', userHasRole.user_id).fetch();
const userRoles = await userModel.roles().fetch();
expect(userRoles).to.have.lengthOf(2);
});
});