Compare commits
3 Commits
dev
...
6028_route
Author | SHA1 | Date |
---|---|---|
Sergio De la torre | 05e503ad48 | |
Sergio De la torre | 2d594a3a20 | |
Sergio De la torre | 3e3c7ea977 |
|
@ -130,13 +130,15 @@ module.exports = Self => {
|
|||
am.name agencyName,
|
||||
u.name AS workerUserName,
|
||||
v.numberPlate AS vehiclePlateNumber,
|
||||
Date_format(r.time, '%H:%i') hour
|
||||
Date_format(r.time, '%H:%i') hour,
|
||||
eu.email
|
||||
FROM route r
|
||||
LEFT JOIN agencyMode am ON am.id = r.agencyModeFk
|
||||
LEFT JOIN agency a ON a.id = am.agencyFk
|
||||
LEFT JOIN vehicle v ON v.id = r.vehicleFk
|
||||
LEFT JOIN worker w ON w.id = r.workerFk
|
||||
LEFT JOIN account.user u ON u.id = w.id`
|
||||
LEFT JOIN account.user u ON u.id = w.id
|
||||
LEFT JOIN account.emailUser eu ON eu.userFk = r.workerFk`
|
||||
);
|
||||
|
||||
stmt.merge(conn.makeSuffix(filter));
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('getRoutesByWorker', () => {
|
||||
it('should return the routes of the worker can view all routes', async() => {
|
||||
const tx = await models.UserConfig.beginTransaction({});
|
||||
|
||||
const deliveryBossId = 57;
|
||||
const options = {transaction: tx};
|
||||
let result;
|
||||
|
||||
try {
|
||||
const ctx = {req: {accessToken: {userId: deliveryBossId}}};
|
||||
await models.UserConfig.create({
|
||||
userFk: 57,
|
||||
warehouseFk: 1
|
||||
}, options);
|
||||
result = await models.Route.getRoutesByWorker(ctx, options);
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
|
||||
expect(result.length).toEqual(7);
|
||||
});
|
||||
|
||||
it('should return the routes of the worker can not view all routes', async() => {
|
||||
const deliveryId = 56;
|
||||
const ctx = {req: {accessToken: {userId: deliveryId}}};
|
||||
const result = await models.Route.getRoutesByWorker(ctx);
|
||||
|
||||
expect(result.length).toEqual(5);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue