diff --git a/db/versions/11147-brownBamboo/00-firstScript.vn.sql b/db/versions/11147-brownBamboo/00-firstScript.vn.sql index aaf1fd34a..eb62b98b0 100644 --- a/db/versions/11147-brownBamboo/00-firstScript.vn.sql +++ b/db/versions/11147-brownBamboo/00-firstScript.vn.sql @@ -1,5 +1,5 @@ -- Place your SQL code here -INSERT INTO vn.state ( name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor) VALUES('Entregado en parte', 13, 3, 'PARTIALLYDELIVERED', NULL, 16, 0, 1, 0, 0, 0, 0, 0, 0, NULL); +INSERT INTO vn.state ( name, `order`, alertLevel, code, sectorProdPriority, nextStateFk, isPreviousPreparable, isPicked, isPreparable, semaphore, isPrintable, isOK, graphCategory, isNotValidated, classColor) VALUES('Entregado en parte', 13, 3, 'PARTIALLY_DELIVERED', NULL, 16, 0, 1, 0, 0, 0, 0, 0, 0, NULL); diff --git a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js index 792e9e824..df7c13aad 100644 --- a/modules/ticket/back/methods/ticket/specs/saveSign.spec.js +++ b/modules/ticket/back/methods/ticket/specs/saveSign.spec.js @@ -8,7 +8,7 @@ describe('Ticket saveSign()', () => { accessToken: {userId: 9} }}; - it(`should throw error if the ticket's alert level is lower than 2`, async() => { + fit(`should throw error if the ticket's alert level is lower than 2`, async() => { const tx = await models.TicketDms.beginTransaction({}); const ticketWithOkState = 12; let error; @@ -26,4 +26,32 @@ describe('Ticket saveSign()', () => { expect(error).toBeDefined(); }); + + fit('should change state for ticket', async() => { + const tx = await models.TicketDms.beginTransaction({}); + const ticketWithOkState = 12; + const ticketStateId = 16; + const ticketCode = 'PARTIALLY_DELIVERED'; + + try { + const options = {transaction: tx}; + const tickets = [ticketWithOkState]; + const state = await models.State.findById(ticketStateId); + await state.updateAttributes({ + code: ticketCode + }, options); + const ticketState = await models.TicketTracking.findById(ticketStateId); + await ticketState.updateAttributes({ + code: ticketCode + }, options); + + await models.Ticket.saveSign(ctx, tickets, options); + await tx.rollback(); + } catch (e) { + await tx.rollback(); + throw e; + } + + expect(ticket.toEqual('DELIVERED')); + }); });