fix: refs #8222 fix pr
gitea/salix/pipeline/pr-master There was a failure building this commit
Details
gitea/salix/pipeline/pr-master There was a failure building this commit
Details
This commit is contained in:
parent
100b709cee
commit
0bb7fa99fd
|
@ -51,7 +51,7 @@ module.exports = Self => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const ticketList = await models.Ticket.find(filter, myOptions);
|
const ticketList = await models.Ticket.find(filter, myOptions);
|
||||||
const hasRefFk = ticketList.some(ticket => ticket.refFk !== null && ticket.refFk !== undefined);
|
const hasRefFk = ticketList.some(ticket => ticket.refFk);
|
||||||
if (hasRefFk)
|
if (hasRefFk)
|
||||||
throw new UserError('There are tickets to be invoiced');
|
throw new UserError('There are tickets to be invoiced');
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,11 @@ describe('zone deletezone()', () => {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
active: activeCtx
|
active: activeCtx
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const zoneId = 4;
|
||||||
const originalTickets = await models.Ticket.find({
|
const originalTickets = await models.Ticket.find({
|
||||||
where: {
|
where: {
|
||||||
zoneFk: 4
|
zoneFk: zoneId
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ticketIDs = originalTickets.map(ticket => ticket.id);
|
ticketIDs = originalTickets.map(ticket => ticket.id);
|
||||||
|
@ -27,12 +29,12 @@ describe('zone deletezone()', () => {
|
||||||
|
|
||||||
it('should delete a zone and update their tickets', async() => {
|
it('should delete a zone and update their tickets', async() => {
|
||||||
const tx = await models.Zone.beginTransaction({});
|
const tx = await models.Zone.beginTransaction({});
|
||||||
|
const zoneId = 4;
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
await models.Zone.deleteZone(ctx, 4, options);
|
await models.Zone.deleteZone(ctx, zoneId, options);
|
||||||
|
|
||||||
const updatedZone = await models.Zone.findById(4, null, options);
|
const updatedZone = await models.Zone.findById(zoneId, null, options);
|
||||||
|
|
||||||
expect(updatedZone).toBeNull();
|
expect(updatedZone).toBeNull();
|
||||||
|
|
||||||
|
@ -45,11 +47,12 @@ describe('zone deletezone()', () => {
|
||||||
|
|
||||||
it('should not delete the zone if it has tickets', async() => {
|
it('should not delete the zone if it has tickets', async() => {
|
||||||
const tx = await models.Zone.beginTransaction({});
|
const tx = await models.Zone.beginTransaction({});
|
||||||
|
const zoneId = 1;
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
await models.Zone.deleteZone(ctx, 1, options);
|
await models.Zone.deleteZone(ctx, zoneId, options);
|
||||||
await tx.rollback();
|
await tx.rollback();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e.message;
|
error = e.message;
|
||||||
|
|
Loading…
Reference in New Issue