5 use RT::Test tests => 22;
6 RT->Config->Set( NotifyActor => 1 );
8 my $queue = RT::Test->load_or_create_queue(
10 CorrespondAddress => 'rt-recipient@example.com',
11 CommentAddress => 'rt-recipient@example.com',
13 ok $queue && $queue->id, 'loaded or created queue';
15 my $user = RT::Test->load_or_create_user(
17 EmailAddress => 'root@localhost',
19 ok $user && $user->id, 'loaded or created user';
25 Message-ID: <some-message-id>
29 my ($status, $id) = RT::Test->send_via_mailgate($mail);
30 ok $id, "created a ticket";
32 my @mail = RT::Test->fetch_caught_mails;
33 is scalar @mail, 1, "autoreply";
34 like $mail[0], qr{^In-Reply-To:\s*<some-message-id>$}mi;
35 like $mail[0], qr{^References:\s*<RT-Ticket-\Q$id\E\@example\.com>}mi;
37 my $ticket = RT::Ticket->new( RT->SystemUser );
39 ok $ticket->id, "loaded ticket";
41 ($status, my ($msg)) = $ticket->Correspond( Content => 'boo' );
42 ok $status, "replied to the ticket";
44 @mail = RT::Test->fetch_caught_mails;
45 is scalar @mail, 1, "reply";
46 like $mail[0], qr{^References:\s*<RT-Ticket-\Q$id\E\@example\.com>$}mi,
47 "no context, so only pseudo header is referenced";
51 my ($ticket) = RT::Test->create_ticket(
53 Requestor => $user->EmailAddress
56 ok $id, "created a ticket";
58 my @mail = RT::Test->fetch_caught_mails;
59 is scalar @mail, 1, "autoreply";
60 like $mail[0], qr{^References:\s*<RT-Ticket-\Q$id\E\@example\.com>}mi;
64 my $scrip = RT::Scrip->new(RT->SystemUser);
65 my ($status, $msg) = $scrip->Create(
66 Description => "Notify requestor on status change",
67 ScripCondition => 'On Status Change',
68 ScripAction => 'Notify Requestors',
69 Template => 'Transaction',
70 Stage => 'TransactionCreate',
73 ok($status, "Scrip created");
75 my ($ticket) = RT::Test->create_ticket(
77 Requestor => $user->EmailAddress,
80 ok $id, "created a ticket";
82 RT::Test->fetch_caught_mails;
83 ($status, $msg) = $ticket->SetStatus('open');
84 ok $status, "changed status";
86 my @mail = RT::Test->fetch_caught_mails;
87 is scalar @mail, 1, "status change notification";
88 like $mail[0], qr{^References:\s*<RT-Ticket-\Q$id\E\@example\.com>}mi;