refactor(ticketSms): refs #6259 ticketSmsToClientSms
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Pablo Natek 2023-12-26 08:20:13 +01:00
parent 35750bc93f
commit 5a1c4ddea0
2 changed files with 4 additions and 20 deletions

View File

@ -7,19 +7,3 @@ INSERT INTO`vn`.`clientSms` (`clientFk`, `smsFk`, `ticketFk`)
JOIN `vn`.`ticket` `t` ON `t`.`id` = `s`.`ticketFk`; JOIN `vn`.`ticket` `t` ON `t`.`id` = `s`.`ticketFk`;
RENAME TABLE `vn`.`ticketSms` TO `vn`.`ticketSms__`; RENAME TABLE `vn`.`ticketSms` TO `vn`.`ticketSms__`;
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`clientSms_beforeInsert`
BEFORE INSERT ON `clientSms`
FOR EACH ROW
BEGIN
DECLARE vTicketOwner INT;
SELECT clientFk INTO vTicketOwner
FROM ticket
WHERE id = NEW.ticketFk;
IF NOT NEW.clientFk = vTicketOwner THEN
CALL util.throw('Unable to send an SMS ticket to a client who is not the owner');
END IF;
END$$

View File

@ -14,10 +14,10 @@ describe('ticket sendSms()', () => {
await models.Ticket.sendSms(ctx, id, destination, message, options); await models.Ticket.sendSms(ctx, id, destination, message, options);
const filter = { const clientSms = await models.ClientSms.findOne(
ticketFk: id {where: {ticketFk: id}},
}; options
const clientSms = await models.ClientSms.findOne(filter, options); );
expect(clientSms.ticketFk).toEqual(id); expect(clientSms.ticketFk).toEqual(id);