User role must be set

This commit is contained in:
Robert Schäfer 2019-07-08 16:44:07 +02:00
parent 99b6254303
commit e77bf31470
3 changed files with 22 additions and 2 deletions

View File

@ -11,7 +11,7 @@ module.exports = {
coverImg: { type: 'string', allow: [null] }, coverImg: { type: 'string', allow: [null] },
deleted: { type: 'boolean', default: false }, deleted: { type: 'boolean', default: false },
disabled: { type: 'boolean', default: false }, disabled: { type: 'boolean', default: false },
role: 'string', role: { type: 'string', required: true, default: 'user' },
publicKey: 'string', publicKey: 'string',
privateKey: 'string', privateKey: 'string',
wasInvited: 'boolean', wasInvited: 'boolean',

View File

@ -0,0 +1,20 @@
import Factory from '../../seed/factories'
import { neode } from '../../bootstrap/neo4j'
const factory = Factory()
const instance = neode()
afterEach(async () => {
await factory.cleanDatabase()
})
describe('role', () => {
it('defaults to `user`', async () => {
const user = await instance.create('User', { name: 'John' })
await expect(user.toJson()).resolves.toEqual(
expect.objectContaining({
role: 'user',
}),
)
})
})

View File

@ -9,7 +9,7 @@ type User {
deleted: Boolean deleted: Boolean
disabled: Boolean disabled: Boolean
disabledBy: User @relation(name: "DISABLED", direction: "IN") disabledBy: User @relation(name: "DISABLED", direction: "IN")
role: UserGroup role: UserGroup!
publicKey: String publicKey: String
invitedBy: User @relation(name: "INVITED", direction: "IN") invitedBy: User @relation(name: "INVITED", direction: "IN")
invited: [User] @relation(name: "INVITED", direction: "OUT") invited: [User] @relation(name: "INVITED", direction: "OUT")