refs #4131 changeStateRefactor #1753
|
@ -47,7 +47,7 @@ module.exports = Self => {
|
||||||
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
for (const id of ticketIds) {
|
for (const id of ticketIds) {
|
||||||
const promise = models.TicketTracking.state(ctx, {
|
const promise = await models.Ticket.state(ctx, {
|
||||||
stateFk: state.id,
|
stateFk: state.id,
|
||||||
workerFk: worker.id,
|
workerFk: worker.id,
|
||||||
ticketFk: id
|
ticketFk: id
|
||||||
|
|
|
@ -47,7 +47,7 @@ describe('ticket state()', () => {
|
||||||
activeCtx.accessToken.userId = salesPersonId;
|
activeCtx.accessToken.userId = salesPersonId;
|
||||||
const params = {ticketFk: 2, stateFk: 3};
|
const params = {ticketFk: 2, stateFk: 3};
|
||||||
|
|
||||||
await models.TicketTracking.state(ctx, params, options);
|
await models.Ticket.state(ctx, params, options);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -69,7 +69,7 @@ describe('ticket state()', () => {
|
||||||
activeCtx.accessToken.userId = employeeId;
|
activeCtx.accessToken.userId = employeeId;
|
||||||
const params = {ticketFk: 11, stateFk: 13};
|
const params = {ticketFk: 11, stateFk: 13};
|
||||||
|
|
||||||
await models.TicketTracking.state(ctx, params, options);
|
await models.Ticket.state(ctx, params, options);
|
||||||
|
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
@ -80,7 +80,8 @@ describe('ticket state()', () => {
|
||||||
expect(error.code).toBe('ACCESS_DENIED');
|
expect(error.code).toBe('ACCESS_DENIED');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be able to create a ticket tracking line for a not editable ticket if the user has the production role', async() => {
|
it('should be able to create a ticket tracking line for a not' +
|
||||||
|
' editable ticket if the user has the production role', async() => {
|
||||||
const tx = await models.TicketTracking.beginTransaction({});
|
const tx = await models.TicketTracking.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -91,7 +92,7 @@ describe('ticket state()', () => {
|
||||||
activeCtx.accessToken.userId = productionId;
|
activeCtx.accessToken.userId = productionId;
|
||||||
const params = {ticketFk: ticket.id, stateFk: 3};
|
const params = {ticketFk: ticket.id, stateFk: 3};
|
||||||
|
|
||||||
const ticketTracking = await models.TicketTracking.state(ctx, params, options);
|
const ticketTracking = await models.Ticket.state(ctx, params, options);
|
||||||
|
|
||||||
expect(ticketTracking.__data.ticketFk).toBe(params.ticketFk);
|
expect(ticketTracking.__data.ticketFk).toBe(params.ticketFk);
|
||||||
expect(ticketTracking.__data.stateFk).toBe(params.stateFk);
|
expect(ticketTracking.__data.stateFk).toBe(params.stateFk);
|
||||||
|
@ -105,7 +106,8 @@ describe('ticket state()', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the ticket tracking line when the user is salesperson, uses the state assigned and a valid worker id', async() => {
|
it('should update the ticket tracking line when the user is salesperson,' +
|
||||||
|
' uses the state assigned and a valid worker id', async() => {
|
||||||
const tx = await models.TicketTracking.beginTransaction({});
|
const tx = await models.TicketTracking.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -115,7 +117,7 @@ describe('ticket state()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 18}}};
|
const ctx = {req: {accessToken: {userId: 18}}};
|
||||||
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
|
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
|
||||||
const params = {ticketFk: ticket.id, stateFk: assignedState.id, workerFk: 1};
|
const params = {ticketFk: ticket.id, stateFk: assignedState.id, workerFk: 1};
|
||||||
const res = await models.TicketTracking.state(ctx, params, options);
|
const res = await models.Ticket.state(ctx, params, options);
|
||||||
|
|
||||||
expect(res.__data.ticketFk).toBe(params.ticketFk);
|
expect(res.__data.ticketFk).toBe(params.ticketFk);
|
||||||
expect(res.__data.stateFk).toBe(params.stateFk);
|
expect(res.__data.stateFk).toBe(params.stateFk);
|
|
@ -1,5 +1,4 @@
|
||||||
module.exports = function(Self) {
|
module.exports = function(Self) {
|
||||||
require('../methods/ticket-tracking/state')(Self);
|
|
||||||
require('../methods/ticket-tracking/setDelivered')(Self);
|
require('../methods/ticket-tracking/setDelivered')(Self);
|
||||||
|
|
||||||
Self.validatesPresenceOf('stateFk', {message: 'State cannot be blank'});
|
Self.validatesPresenceOf('stateFk', {message: 'State cannot be blank'});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
// Methods
|
// Methods
|
||||||
require('./ticket-methods')(Self);
|
require('./ticket-methods')(Self);
|
||||||
|
require('../methods/ticket/state')(Self);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue