8032-devToTest_2440 #3009
|
@ -1,6 +1,6 @@
|
||||||
DROP TABLE IF EXISTS vn.wagonTypeTray;
|
DROP TABLE IF EXISTS vn.wagonTypeTray;
|
||||||
|
|
||||||
CREATE TABLE vn.wagonTypeTray (
|
CREATE OR REPLACE TABLE vn.wagonTypeTray (
|
||||||
id INT UNSIGNED auto_increment NULL,
|
id INT UNSIGNED auto_increment NULL,
|
||||||
wagonTypeFk int(11) unsigned NULL,
|
wagonTypeFk int(11) unsigned NULL,
|
||||||
height INT UNSIGNED NULL,
|
height INT UNSIGNED NULL,
|
||||||
|
|
|
@ -236,6 +236,8 @@
|
||||||
"Cannot send mail": "Cannot send mail",
|
"Cannot send mail": "Cannot send mail",
|
||||||
"CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`",
|
"CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`": "CONSTRAINT `chkParkingCodeFormat` failed for `vn`.`parking`",
|
||||||
"This postcode already exists": "This postcode already exists",
|
"This postcode already exists": "This postcode already exists",
|
||||||
"Original invoice not found": "Original invoice not found"
|
"Original invoice not found": "Original invoice not found",
|
||||||
|
"There is already a tray with the same height": "There is already a tray with the same height",
|
||||||
|
"The height must be greater than 50cm": "The height must be greater than 50cm",
|
||||||
|
"The maximum height of the wagon is 200cm": "The maximum height of the wagon is 200cm"
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,7 +374,6 @@
|
||||||
"Original invoice not found": "Factura original no encontrada",
|
"Original invoice not found": "Factura original no encontrada",
|
||||||
"The entry has no lines or does not exist": "La entrada no tiene lineas o no existe",
|
"The entry has no lines or does not exist": "La entrada no tiene lineas o no existe",
|
||||||
"There is already a tray with the same height": "Ya existe una bandeja con la misma altura",
|
"There is already a tray with the same height": "Ya existe una bandeja con la misma altura",
|
||||||
"You must define wagon and height": "Debes definir un tipo de vagón y la altura",
|
"The height must be greater than 50cm": "La altura debe ser superior a 50cm",
|
||||||
"The maximum height of the wagon is": "La altura máxima es %d",
|
"The maximum height of the wagon is 200cm": "La altura máxima es 200cm"
|
||||||
"The height must be greater than": "The height must be greater than %d"
|
|
||||||
}
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
|
fdescribe('WagonTray max height()', () => {
|
||||||
|
it(`should throw an error if the tray's height is above the maximum of the wagon`, async() => {
|
||||||
|
const tx = await models.WagonTypeTray.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
await models.WagonTypeTray.create({height: 210, wagonTypeFk: 1, wagonTypeColorFk: 4}, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toBe('The maximum height of the wagon is 200cm');
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should throw an error if the tray's height is already in the wagon`, async() => {
|
||||||
|
const tx = await models.WagonTypeTray.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
await models.WagonTypeTray.create({height: 50, wagonTypeFk: 1, wagonTypeColorFk: 2}, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toBe('There is already a tray with the same height');
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should throw an error if the tray's height is below the minimum between the trays`, async() => {
|
||||||
|
const tx = await models.WagonTypeTray.beginTransaction({});
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
|
await models.WagonTypeTray.create({height: 40, wagonTypeFk: 1, wagonTypeColorFk: 4}, options);
|
||||||
|
|
||||||
|
await tx.rollback();
|
||||||
|
} catch (e) {
|
||||||
|
await tx.rollback();
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error.message).toBe('The height must be greater than 50cm');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -15,14 +15,11 @@ module.exports = Self => {
|
||||||
if (tray.length)
|
if (tray.length)
|
||||||
throw new UserError('There is already a tray with the same height');
|
throw new UserError('There is already a tray with the same height');
|
||||||
|
|
||||||
if (!wagonTypeFk && !height)
|
|
||||||
throw new UserError('You must define wagon and height');
|
|
||||||
|
|
||||||
if (height < config.minHeightBetweenTrays)
|
if (height < config.minHeightBetweenTrays)
|
||||||
throw new UserError('The height must be greater than', 'HEIGHT_GREATER_THAN', config.minHeightBetweenTrays);
|
throw new UserError('The height must be greater than 50cm');
|
||||||
|
|
||||||
if (height > config.maxWagonHeight)
|
if (height > config.maxWagonHeight)
|
||||||
throw new UserError('The maximum height of the wagon is', 'MAX_WAGON_HEIGHT', config.maxWagonHeight);
|
throw new UserError('The maximum height of the wagon is 200cm');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue