[Rt-commit] rt branch, 4.2/create-squelching-with-tests, created. rt-4.2.10-1-g47663a6

Dave Goehrig dave at bestpractical.com
Wed Jan 4 14:27:59 EST 2017


The branch, 4.2/create-squelching-with-tests has been created
        at  47663a6a8aa54b2a3b59e39cec22247e43632b32 (commit)

- Log -----------------------------------------------------------------
commit 47663a6a8aa54b2a3b59e39cec22247e43632b32
Author: Dave Goehrig <dave at bestpractical.com>
Date:   Wed Jan 4 14:18:13 2017 -0500

    Added tests for SquelchMailTo
    
    Made the API for _SquelchMailTo match the usage
    and added tests to the ticket api and mailing.
    
    Fixes T#178085

diff --git a/lib/RT/Ticket.pm b/lib/RT/Ticket.pm
index 3822761..8b76780 100644
--- a/lib/RT/Ticket.pm
+++ b/lib/RT/Ticket.pm
@@ -707,7 +707,7 @@ sub SquelchMailTo {
 
 sub _SquelchMailTo {
     my $self = shift;
-    if (@_) {
+    while (@_) {
         my $attr = shift;
         $self->AddAttribute( Name => 'SquelchMailTo', Content => $attr )
             unless grep { $_->Content eq $attr }
diff --git a/t/api/ticket.t b/t/api/ticket.t
index c5f1e24..eee865b 100644
--- a/t/api/ticket.t
+++ b/t/api/ticket.t
@@ -179,7 +179,11 @@ 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");
 
 }
 
diff --git a/t/mail/one-time-recipients.t b/t/mail/one-time-recipients.t
index 1bc172d..f305887 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";
@@ -133,6 +155,7 @@ warnings_are {
         );
         ok $status, "replied to a ticket";
     }  { Cc => 'test at localhost' };
+
 } [];
 
 diag "Requestor is an RT address";

-----------------------------------------------------------------------


More information about the rt-commit mailing list