This commit is contained in:
parent
8188bdbcb0
commit
14afd8246a
|
@ -134,12 +134,14 @@ module.exports = Self => {
|
|||
|
||||
if (isFreelance || !client) {
|
||||
const [{password}] = await models.Worker.rawSql('SELECT account.passwordGenerate() as password;');
|
||||
const freelancer = isFreelance && await models.VnRole.findOne({fields: ['id'], where: {name: 'freelancer'}});
|
||||
|
||||
user = await models.VnUser.create({
|
||||
name,
|
||||
nickname,
|
||||
password,
|
||||
email,
|
||||
roleFk,
|
||||
roleFk: freelancer ? freelancer.id : roleFk,
|
||||
}, myOptions);
|
||||
|
||||
await models.Account.create({
|
||||
|
|
|
@ -97,6 +97,19 @@ describe('Worker new', () => {
|
|||
await models.Worker.destroyById(newWorker.id);
|
||||
}
|
||||
});
|
||||
|
||||
it('should create a new external worker', async() => {
|
||||
let newWorker;
|
||||
try {
|
||||
newWorker = await createWorker(ctx, undefined, {isFreelance: true});
|
||||
const client = await models.Client.findById(newWorker.id);
|
||||
|
||||
expect(newWorker.id).toBeDefined();
|
||||
expect(client).toBeNull();
|
||||
} finally {
|
||||
await removeWorker(newWorker.id);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
async function removeWorker(id) {
|
||||
|
|
Loading…
Reference in New Issue