feat(ticket.state): refs #4131 convert changeState to State
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Pablo Natek 2023-10-27 13:41:32 +02:00
parent 9708f66cef
commit 42bbdf9814
5 changed files with 10 additions and 8 deletions

View File

@ -47,7 +47,7 @@ module.exports = Self => {
const promises = [];
for (const id of ticketIds) {
const promise = models.TicketTracking.state(ctx, {
const promise = await models.Ticket.state(ctx, {
stateFk: state.id,
workerFk: worker.id,
ticketFk: id

View File

@ -47,7 +47,7 @@ describe('ticket state()', () => {
activeCtx.accessToken.userId = salesPersonId;
const params = {ticketFk: 2, stateFk: 3};
await models.TicketTracking.state(ctx, params, options);
await models.Ticket.state(ctx, params, options);
await tx.rollback();
} catch (e) {
@ -69,7 +69,7 @@ describe('ticket state()', () => {
activeCtx.accessToken.userId = employeeId;
const params = {ticketFk: 11, stateFk: 13};
await models.TicketTracking.state(ctx, params, options);
await models.Ticket.state(ctx, params, options);
await tx.rollback();
} catch (e) {
@ -80,7 +80,8 @@ describe('ticket state()', () => {
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({});
try {
@ -91,7 +92,7 @@ describe('ticket state()', () => {
activeCtx.accessToken.userId = productionId;
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.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({});
try {
@ -115,7 +117,7 @@ describe('ticket state()', () => {
const ctx = {req: {accessToken: {userId: 18}}};
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
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.stateFk).toBe(params.stateFk);

View File

@ -1,5 +1,4 @@
module.exports = function(Self) {
require('../methods/ticket-tracking/state')(Self);
require('../methods/ticket-tracking/setDelivered')(Self);
Self.validatesPresenceOf('stateFk', {message: 'State cannot be blank'});

View File

@ -1,4 +1,5 @@
module.exports = Self => {
// Methods
require('./ticket-methods')(Self);
require('../methods/ticket/state')(Self);
};