4 use RT::Test tests => 22;
5 RT->Config->Set( NotifyActor => 1 );
7 my $queue = RT::Test->load_or_create_queue(
9 CorrespondAddress => 'rt-recipient@example.com',
10 CommentAddress => 'rt-recipient@example.com',
12 ok $queue && $queue->id, 'loaded or created queue';
14 my $user = RT::Test->load_or_create_user(
16 EmailAddress => 'root@localhost',
18 ok $user && $user->id, 'loaded or created user';
24 Message-ID: <some-message-id>
28 my ($status, $id) = RT::Test->send_via_mailgate($mail);
29 ok $id, "created a ticket";
31 my @mail = RT::Test->fetch_caught_mails;
32 is scalar @mail, 1, "autoreply";
33 like $mail[0], qr{^In-Reply-To:\s*<some-message-id>$}mi;
34 like $mail[0], qr{^References:\s*<RT-Ticket-\Q$id\E\@example\.com>}mi;
36 my $ticket = RT::Ticket->new( RT->SystemUser );
38 ok $ticket->id, "loaded ticket";
40 ($status, my ($msg)) = $ticket->Correspond( Content => 'boo' );
41 ok $status, "replied to the ticket";
43 @mail = RT::Test->fetch_caught_mails;
44 is scalar @mail, 1, "reply";
45 like $mail[0], qr{^References:\s*<RT-Ticket-\Q$id\E\@example\.com>$}mi,
46 "no context, so only pseudo header is referenced";
50 my ($ticket) = RT::Test->create_ticket(
52 Requestor => $user->EmailAddress
55 ok $id, "created a ticket";
57 my @mail = RT::Test->fetch_caught_mails;
58 is scalar @mail, 1, "autoreply";
59 like $mail[0], qr{^References:\s*<RT-Ticket-\Q$id\E\@example\.com>}mi;
63 my $scrip = RT::Scrip->new(RT->SystemUser);
64 my ($status, $msg) = $scrip->Create(
65 Description => "Notify requestor on status change",
66 ScripCondition => 'On Status Change',
67 ScripAction => 'Notify Requestors',
68 Template => 'Transaction',
69 Stage => 'TransactionCreate',
72 ok($status, "Scrip created");
74 my ($ticket) = RT::Test->create_ticket(
76 Requestor => $user->EmailAddress,
79 ok $id, "created a ticket";
81 RT::Test->fetch_caught_mails;
82 ($status, $msg) = $ticket->SetStatus('open');
83 ok $status, "changed status";
85 my @mail = RT::Test->fetch_caught_mails;
86 is scalar @mail, 1, "status change notification";
87 like $mail[0], qr{^References:\s*<RT-Ticket-\Q$id\E\@example\.com>}mi;