5 use RT::Test tests => 38;
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';
20 diag "Reply to ticket with actor as one time cc";
22 my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
23 my ($status, undef, $msg) = $ticket->Create(
26 Requestor => 'root@localhost',
28 ok $status, "created ticket";
30 my @mails = RT::Test->fetch_caught_mails;
31 ok @mails, "got some outgoing emails";
32 foreach my $mail ( @mails ) {
33 my $entity = parse_mail( $mail );
34 my $to = $entity->head->get('To');
36 is $to, 'root@localhost', 'got mail'
39 RT->Config->Set( NotifyActor => 1 );
40 ($status, $msg) = $ticket->Correspond(
41 Content => 'test mail',
43 ok $status, "replied to a ticket";
45 @mails = RT::Test->fetch_caught_mails;
46 ok @mails, "got some outgoing emails";
47 foreach my $mail ( @mails ) {
48 my $entity = parse_mail( $mail );
49 my $to = $entity->head->get('To');
51 is $to, 'root@localhost', 'got mail'
54 RT->Config->Set( NotifyActor => 0 );
55 ($status, $msg) = $ticket->Correspond(
56 Content => 'test mail',
58 ok $status, "replied to a ticket";
60 @mails = RT::Test->fetch_caught_mails;
61 ok !@mails, "no mail - don't notify actor";
63 ($status, $msg) = $ticket->Correspond(
64 Content => 'test mail',
65 CcMessageTo => 'root@localhost',
67 ok $status, "replied to a ticket";
69 @mails = RT::Test->fetch_caught_mails;
70 ok @mails, "got some outgoing emails";
71 foreach my $mail ( @mails ) {
72 my $entity = parse_mail( $mail );
73 my $to = $entity->head->get('Cc');
75 is $to, 'root@localhost', 'got mail'
79 diag "Reply to ticket with requestor squelched";
81 my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
82 my ($status, undef, $msg) = $ticket->Create(
85 Requestor => 'test@localhost',
87 ok $status, "created ticket";
89 my @mails = RT::Test->fetch_caught_mails;
90 ok @mails, "got some outgoing emails";
91 foreach my $mail ( @mails ) {
92 my $entity = parse_mail( $mail );
93 my $to = $entity->head->get('To');
95 is $to, 'test@localhost', 'got mail'
98 ($status, $msg) = $ticket->Correspond(
99 Content => 'test mail',
101 ok $status, "replied to a ticket";
103 @mails = RT::Test->fetch_caught_mails;
104 ok @mails, "got some outgoing emails";
105 foreach my $mail ( @mails ) {
106 my $entity = parse_mail( $mail );
107 my $to = $entity->head->get('To');
108 $to =~ s/^\s+|\s+$//;
109 is $to, 'test@localhost', 'got mail'
112 $ticket->SquelchMailTo('test@localhost');
113 ($status, $msg) = $ticket->Correspond(
114 Content => 'test mail',
116 ok $status, "replied to a ticket";
118 @mails = RT::Test->fetch_caught_mails;
119 ok !@mails, "no mail - squelched";
121 ($status, $msg) = $ticket->Correspond(
122 Content => 'test mail',
123 CcMessageTo => 'test@localhost',
125 ok $status, "replied to a ticket";
127 @mails = RT::Test->fetch_caught_mails;
128 ok @mails, "got some outgoing emails";
129 foreach my $mail ( @mails ) {
130 my $entity = parse_mail( $mail );
131 my $to = $entity->head->get('Cc');
132 $to =~ s/^\s+|\s+$//;
133 is $to, 'test@localhost', 'got mail'
137 diag "Reply to ticket with requestor squelched";
139 my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
140 my ($status, undef, $msg) = $ticket->Create(
143 Requestor => 'test@localhost',
145 ok $status, "created ticket";
147 my @mails = RT::Test->fetch_caught_mails;
148 ok @mails, "got some outgoing emails";
149 foreach my $mail ( @mails ) {
150 my $entity = parse_mail( $mail );
151 my $to = $entity->head->get('To');
152 $to =~ s/^\s+|\s+$//;
153 is $to, 'test@localhost', 'got mail'
156 ($status, $msg) = $ticket->Correspond(
157 Content => 'test mail',
159 ok $status, "replied to a ticket";
161 @mails = RT::Test->fetch_caught_mails;
162 ok @mails, "got some outgoing emails";
163 foreach my $mail ( @mails ) {
164 my $entity = parse_mail( $mail );
165 my $to = $entity->head->get('To');
166 $to =~ s/^\s+|\s+$//;
167 is $to, 'test@localhost', 'got mail'
170 ($status, $msg) = $ticket->Correspond(
171 Content => 'test mail',
172 SquelchMailTo => ['test@localhost'],
174 ok $status, "replied to a ticket";
176 @mails = RT::Test->fetch_caught_mails;
177 ok !@mails, "no mail - squelched";
179 ($status, $msg) = $ticket->Correspond(
180 Content => 'test mail',
182 ok $status, "replied to a ticket";
184 @mails = RT::Test->fetch_caught_mails;
185 ok @mails, "got some outgoing emails";
186 foreach my $mail ( @mails ) {
187 my $entity = parse_mail( $mail );
188 my $to = $entity->head->get('To');
189 $to =~ s/^\s+|\s+$//;
190 is $to, 'test@localhost', 'got mail'
193 ($status, $msg) = $ticket->Correspond(
194 Content => 'test mail',
195 CcMessageTo => 'test@localhost',
196 SquelchMailTo => ['test@localhost'],
198 ok $status, "replied to a ticket";
200 @mails = RT::Test->fetch_caught_mails;
201 ok @mails, "got some outgoing emails";
202 foreach my $mail ( @mails ) {
203 my $entity = parse_mail( $mail );
204 my $to = $entity->head->get('Cc');
205 $to =~ s/^\s+|\s+$//;
206 is $to, 'test@localhost', 'got mail'