refs #6259 TicketSms to ClientSms #1900
|
@ -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$$
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue