[Rt-commit] rt branch, 4.2-trunk, updated. rt-4.2.13-104-gbba8f5f
Shawn Moore
shawn at bestpractical.com
Tue Jan 10 15:20:16 EST 2017
The branch, 4.2-trunk has been updated
via bba8f5fb4838c98f4ba07b381684679b8b3360b1 (commit)
via b9a3f9290fb6b70a7b701008834fb71e6d156b25 (commit)
via 27d16e464fe3e557a7e2722671684f59d9210b9e (commit)
from 47326ea909ac00f0c2dd277a136af996a3fcb096 (commit)
Summary of changes:
lib/RT/Ticket.pm | 13 +++--
t/api/ticket.t | 13 +++++
t/mail/one-time-recipients.t | 22 ++++++++
t/mail/squelched-email-recipients.t | 109 ++++++++++++++++++++++++++++++++++++
4 files changed, 151 insertions(+), 6 deletions(-)
create mode 100644 t/mail/squelched-email-recipients.t
- Log -----------------------------------------------------------------
commit 27d16e464fe3e557a7e2722671684f59d9210b9e
Author: Dave Goehrig <dave at bestpractical.com>
Date: Wed Jan 4 14:18:13 2017 -0500
Added tests for SquelchMailTo
diff --git a/t/api/ticket.t b/t/api/ticket.t
index c5f1e24..cfba3e9 100644
--- a/t/api/ticket.t
+++ b/t/api/ticket.t
@@ -179,7 +179,20 @@ ok($ret, "Removed nobody as a squelched recipient - ".$msg);
@returned = $t->SquelchMailTo();
is($#returned, -1, "The ticket has no squelched recipients". join(',', at returned));
+ at returned = $t->SquelchMailTo('somebody at example.com','nobody at example.com');
+is($#returned, 1, "The ticket has two squelched recipients, multiple args");
+ at returned = $t->SquelchMailTo('third at example.com');
+is($#returned, 2, "The ticket has three squelched recipients, additive calls");
+
+my $t2 = RT::Ticket->new(RT->SystemUser);
+ok($t2->Create(Queue => 'general', Subject => 'SquelchTest', SquelchMailTo => [ 'nobody at example.com', 'test at example.com' ]));
+my @returned2 = $t2->SquelchMailTo();
+is($#returned2,1, "The ticket has two squelched recipients");
+
+$t2->SquelchMailTo('test at example.com');
+my @returned3 = $t2->SquelchMailTo();
+is($#returned2,1, "The ticket still has two squelched recipients, no duplicate squelchers");
}
diff --git a/t/mail/one-time-recipients.t b/t/mail/one-time-recipients.t
index 1bc172d..bdbcc52 100644
--- a/t/mail/one-time-recipients.t
+++ b/t/mail/one-time-recipients.t
@@ -89,6 +89,28 @@ warnings_are {
);
ok $status, "replied to a ticket";
} { Cc => 'test at localhost' };
+}[];
+
+diag "Reply to ticket with multiple requestors squelched";
+warnings_are {
+ my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
+ mail_ok {
+ my ($status, undef, $msg) = $ticket->Create(
+ Queue => $queue->id,
+ Subject => 'test squelch',
+ Requestor => ['test at localhost','bob at localhost','fred at localhost' ],
+ );
+ ok $status, "created ticket";
+ } { To => 'bob at localhost, fred at localhost, test at localhost' };
+
+ mail_ok {
+ my ($status,$msg) = $ticket->Correspond(
+ Content => 'squelched email',
+ SquelchMailTo => ['bob at localhost', 'fred at localhost'],
+ );
+ ok $status, "replied to a ticket";
+ } { To => 'test at localhost' };
+
} [];
diag "Reply to ticket with requestor squelched";
diff --git a/t/mail/squelched-email-recipients.t b/t/mail/squelched-email-recipients.t
new file mode 100644
index 0000000..addb22f
--- /dev/null
+++ b/t/mail/squelched-email-recipients.t
@@ -0,0 +1,109 @@
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+use RT::Test::Email;
+use Test::Warn;
+
+my $queue = RT::Test->load_or_create_queue(
+ Name => 'General',
+ CorrespondAddress => 'rt-recipient at example.com',
+ CommentAddress => 'rt-recipient at example.com',
+);
+ok $queue && $queue->id, 'loaded or created queue';
+
+my $user = RT::Test->load_or_create_user(
+ Name => 'root',
+ EmailAddress => 'root at localhost',
+);
+ok $user && $user->id, 'loaded or created root user';
+
+my $test_user = RT::Test->load_or_create_user(
+ Name => 'test',
+ EmailAddress => 'test at localhost',
+);
+ok $test_user && $test_user->id, 'loaded or created test user';
+
+my $nobody_user = RT::Test->load_or_create_user(
+ Name => 'nobody',
+ EmailAddress => 'nobody at localhost',
+);
+ok $nobody_user && $nobody_user->id, 'loaded or created test user';
+
+
+diag "Test creation of emails with a squelched requestor";
+warnings_are {
+ my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
+ mail_ok {
+ my ($status, undef, $msg) = $ticket->Create(
+ Queue => $queue->id,
+ Subject => 'test',
+ Requestor => [ 'root at localhost', 'test at localhost', 'nobody at localhost' ],
+ SquelchMailTo => [ 'test at localhost' ],
+ );
+ ok $status, "created ticket";
+ } { To => 'nobody at localhost, root at localhost' };
+
+ RT->Config->Set( NotifyActor => 1 );
+ mail_ok {
+ my ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ );
+ ok $status, "replied to a ticket";
+ } { To => 'nobody at localhost, root at localhost' };
+
+ RT->Config->Set( NotifyActor => 0 );
+ mail_ok {
+ my ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ );
+ ok $status, "replied to a ticket";
+ } { To => 'nobody at localhost' };
+
+ mail_ok {
+ my ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ CcMessageTo => 'root at localhost',
+ );
+ ok $status, "replied to a ticket";
+ } { Cc => 'root at localhost'},{ To => 'nobody at localhost' };
+} [];
+
+diag "Reply to ticket with multiple requestors squelched";
+warnings_are {
+ my $ticket = RT::Ticket->new( RT::CurrentUser->new( $user ) );
+ mail_ok {
+ my ($status, undef, $msg) = $ticket->Create(
+ Queue => $queue->id,
+ Subject => 'test',
+ Requestor => [ 'root at localhost', 'test at localhost', 'nobody at localhost' ],
+ SquelchMailTo => [ 'root at localhost', 'nobody at localhost' ]
+ );
+ ok $status, "created ticket";
+ } { To => 'test at localhost' };
+
+ mail_ok {
+ my ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ );
+ ok $status, "replied to a ticket";
+ } { To => 'test at localhost' };
+
+ $ticket->SquelchMailTo('test at localhost');
+ mail_ok {
+ my ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ );
+ ok $status, "replied to a ticket";
+ };
+
+ mail_ok {
+ my ($status, $msg) = $ticket->Correspond(
+ Content => 'test mail',
+ CcMessageTo => 'test at localhost',
+ );
+ ok $status, "replied to a ticket";
+ } { Cc => 'test at localhost' };
+}[];
+
+done_testing;
commit b9a3f9290fb6b70a7b701008834fb71e6d156b25
Author: Dave Goehrig <dave at bestpractical.com>
Date: Tue Jan 10 19:49:41 2017 +0000
Have _SquelchMailTo accept a list of email addresses
This fixes a bug where only the first, rather than every, email address
squelched in a ticket creation transaction was respected. This bug arose
from the discrepency between the documentation and handling of
RT::Ticket->Create's SquelchMailTo, which claims that it accepts a list
of email addresses, and the implementation of
RT::Ticket->_SquelchMailTo, which accepts only a single email address.
Fixes: I#31600
diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 3822761..b00d594 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -680,13 +680,14 @@ sub DeleteWatcher {
-=head2 SquelchMailTo [EMAIL]
+=head2 SquelchMailTo ADDRESSES
-Takes an optional email address to never email about updates to this ticket.
-
-
-Returns an array of the RT::Attribute objects for this ticket's 'SquelchMailTo' attributes.
+Takes a list of email addresses to never email about updates to this ticket.
+Subsequent calls to this method add, rather than replace, the list of
+squelched addresses.
+Returns an array of the L<RT::Attribute> objects for this ticket's
+'SquelchMailTo' attributes.
=cut
@@ -707,7 +708,7 @@ sub SquelchMailTo {
sub _SquelchMailTo {
my $self = shift;
- if (@_) {
+ while (@_) {
my $attr = shift;
$self->AddAttribute( Name => 'SquelchMailTo', Content => $attr )
unless grep { $_->Content eq $attr }
commit bba8f5fb4838c98f4ba07b381684679b8b3360b1
Merge: 47326ea b9a3f92
Author: Shawn M Moore <shawn at bestpractical.com>
Date: Tue Jan 10 20:20:06 2017 +0000
Merge branch '4.2/create-squelching-with-tests' into 4.2-trunk
-----------------------------------------------------------------------
More information about the rt-commit
mailing list