refs #6259 TicketSms to ClientSms #1900

Merged
pablone merged 10 commits from 6259-ticketSmsJoinClientSms into dev 2024-01-08 07:23:16 +00:00
2 changed files with 4 additions and 20 deletions
Showing only changes of commit 5a1c4ddea0 - Show all commits

View File

@ -7,19 +7,3 @@ INSERT INTO`vn`.`clientSms` (`clientFk`, `smsFk`, `ticketFk`)
JOIN `vn`.`ticket` `t` ON `t`.`id` = `s`.`ticketFk`;
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);
const filter = {
ticketFk: id
};
const clientSms = await models.ClientSms.findOne(filter, options);
const clientSms = await models.ClientSms.findOne(
{where: {ticketFk: id}},
options
);
expect(clientSms.ticketFk).toEqual(id);