Bug #1514 route.volume No actualiza el volumen
gitea/salix/dev This commit looks good Details

This commit is contained in:
Bernat 2019-06-11 12:25:17 +02:00
parent 5ce33fbefd
commit 4729a7e9a9
2 changed files with 24 additions and 11 deletions

View File

@ -0,0 +1,17 @@
DROP procedure IF EXISTS `vn`.`routeUpdateM3`;
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`routeUpdateM3`(vRoute INT)
BEGIN
UPDATE vn.route r
JOIN (SELECT routeFk, SUM(volume) AS m3
FROM ticketGetVolume
WHERE routeFk = vRoute
) v ON v.routeFk = r.id
SET r.m3 = v.m3;
END$$
DELIMITER ;

View File

@ -1,20 +1,17 @@
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');
// Check procedure from task #1514 describe('route updateVolume()', () => {
xdescribe('route updateVolume()', () => {
const routeId = 1; const routeId = 1;
const workerFk = 9; const workerFk = 9;
const ctx = {req: {accessToken: {userId: workerFk}}}; const ctx = {req: {accessToken: {userId: workerFk}}};
let originalRoute; let originalRoute;
let firstUpdatedTicket; let ticketRestore;
let secondUpdatedTicket;
let logIdToDestroy; let logIdToDestroy;
afterAll(async done => { afterAll(async done => {
// await originalRoute.updateAttributes({m3: 0.2}); await originalRoute.updateAttributes({m3: 0.2});
// await firstUpdatedTicket.updateAttributes({routeFk: 4}); await ticketRestore.updateAttributes({routeFk: 4});
// await secondUpdatedTicket.updateAttributes({routeFk: 4});
await app.models.RouteLog.destroyById(logIdToDestroy); await app.models.RouteLog.destroyById(logIdToDestroy);
done(); done();
}); });
@ -26,11 +23,10 @@ xdescribe('route updateVolume()', () => {
}); });
it('should confirm the route volume is updated when a ticket is added', async() => { it('should confirm the route volume is updated when a ticket is added', async() => {
// firstUpdatedTicket = await app.models.Ticket.findById(16); ticketRestore = await app.models.Ticket.findById(8);
secondUpdatedTicket = await app.models.Ticket.findById(8); let updatedTicket = await app.models.Ticket.findById(8);
// await firstUpdatedTicket.updateAttributes({routeFk: routeId}); await updatedTicket.updateAttributes({routeFk: routeId});
await secondUpdatedTicket.updateAttributes({routeFk: routeId});
await app.models.Route.updateVolume(ctx, routeId); await app.models.Route.updateVolume(ctx, routeId);
let updatedRoute = await app.models.Route.findById(routeId); let updatedRoute = await app.models.Route.findById(routeId);