Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

support customized forward message and use scrip to send forwarded me…

…ssage

now we record the forward transaction with customized message and use a scrip
bound to it to actually send the message.
(SendForward action is newly added for it)

As we use SendEmail action, invalid recipients will be stripped, so I removed
"rt-test" recipient in test.
  • Loading branch information...
commit ab8edd262c5741ea25f1ff521d6721d3f78fabd3 1 parent 62a4a2b
sunnavy sunnavy authored
19 etc/initialdata
@@ -98,6 +98,9 @@
98 98 { Name => 'Extract Subject Tag', # loc
99 99 Description => 'Extract tags from a Transaction\'s subject and add them to the Ticket\'s subject.', # loc
100 100 ExecModule => 'ExtractSubjectTag' },
  101 + { Name => 'Send Forward', # loc
  102 + Description => 'Send forwarded message', # loc
  103 + ExecModule => 'SendForward', },
101 104 );
102 105
103 106 @ScripConditions = (
@@ -400,17 +403,21 @@ The ticket has been approved, you may now start to act on it.
400 403 },
401 404 { Queue => 0,
402 405 Name => "Forward", # loc
403   - Description => "Heading of a forwarded message", # loc
  406 + Description => "Forwarded message", # loc
404 407 Content => q{
405 408 This is a forward of transaction #{$Transaction->id} of ticket #{ $Ticket->id }
  409 +
  410 +{ $ForwardTransaction->Content }
406 411 }
407 412 },
408 413 { Queue => 0,
409 414 Name => "Forward Ticket", # loc
410   - Description => "Heading of a forwarded Ticket", # loc
  415 + Description => "Forwarded ticket message", # loc
411 416 Content => q{
412 417
413 418 This is a forward of ticket #{ $Ticket->id }
  419 +
  420 +{ $ForwardTransaction->Content }
414 421 }
415 422 },
416 423 { Queue => 0,
@@ -555,6 +562,14 @@ Hour: { $SubscriptionObj->SubValue('Hour') }
555 562 ScripCondition => 'On Transaction',
556 563 ScripAction => 'Extract Subject Tag',
557 564 Template => 'Blank' },
  565 + { Description => 'On Forward Transaction Send forwarded message',
  566 + ScripCondition => 'On Forward Transaction',
  567 + ScripAction => 'Send Forward',
  568 + Template => 'Forward' },
  569 + { Description => 'On Forward Ticket Send forwarded message',
  570 + ScripCondition => 'On Forward Ticket',
  571 + ScripAction => 'Send Forward',
  572 + Template => 'Forward Ticket' },
558 573 );
559 574
560 575 @ACL = (
16 lib/RT/Action/SendEmail.pm
@@ -151,13 +151,15 @@ Builds an outgoing email we're going to send using scrip's template.
151 151 sub Prepare {
152 152 my $self = shift;
153 153
154   - my ( $result, $message ) = $self->TemplateObj->Parse(
155   - Argument => $self->Argument,
156   - TicketObj => $self->TicketObj,
157   - TransactionObj => $self->TransactionObj
158   - );
159   - if ( !$result ) {
160   - return (undef);
  154 + unless ( $self->TemplateObj->MIMEObj ) {
  155 + my ( $result, $message ) = $self->TemplateObj->Parse(
  156 + Argument => $self->Argument,
  157 + TicketObj => $self->TicketObj,
  158 + TransactionObj => $self->TransactionObj
  159 + );
  160 + if ( !$result ) {
  161 + return (undef);
  162 + }
161 163 }
162 164
163 165 my $MIMEObj = $self->TemplateObj->MIMEObj;
148 lib/RT/Action/SendForward.pm
... ... @@ -0,0 +1,148 @@
  1 +# BEGIN BPS TAGGED BLOCK {{{
  2 +#
  3 +# COPYRIGHT:
  4 +#
  5 +# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
  6 +# <sales@bestpractical.com>
  7 +#
  8 +# (Except where explicitly superseded by other copyright notices)
  9 +#
  10 +#
  11 +# LICENSE:
  12 +#
  13 +# This work is made available to you under the terms of Version 2 of
  14 +# the GNU General Public License. A copy of that license should have
  15 +# been provided with this software, but in any event can be snarfed
  16 +# from www.gnu.org.
  17 +#
  18 +# This work is distributed in the hope that it will be useful, but
  19 +# WITHOUT ANY WARRANTY; without even the implied warranty of
  20 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21 +# General Public License for more details.
  22 +#
  23 +# You should have received a copy of the GNU General Public License
  24 +# along with this program; if not, write to the Free Software
  25 +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  26 +# 02110-1301 or visit their web page on the internet at
  27 +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
  28 +#
  29 +#
  30 +# CONTRIBUTION SUBMISSION POLICY:
  31 +#
  32 +# (The following paragraph is not intended to limit the rights granted
  33 +# to you to modify and distribute this software under the terms of
  34 +# the GNU General Public License and is only of importance to you if
  35 +# you choose to contribute your changes and enhancements to the
  36 +# community by submitting them to Best Practical Solutions, LLC.)
  37 +#
  38 +# By intentionally submitting any modifications, corrections or
  39 +# derivatives to this work, or any other work intended for use with
  40 +# Request Tracker, to Best Practical Solutions, LLC, you confirm that
  41 +# you are the copyright holder for those contributions and you grant
  42 +# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
  43 +# royalty-free, perpetual, license to use, copy, create derivative
  44 +# works based on those contributions, and sublicense and distribute
  45 +# those contributions and any derivatives thereof.
  46 +#
  47 +# END BPS TAGGED BLOCK }}}
  48 +
  49 +#
  50 +package RT::Action::SendForward;
  51 +
  52 +use strict;
  53 +use warnings;
  54 +
  55 +use base qw(RT::Action::SendEmail);
  56 +
  57 +use Email::Address;
  58 +
  59 +=head2 Prepare
  60 +
  61 +=cut
  62 +
  63 +sub Prepare {
  64 + my $self = shift;
  65 +
  66 + my $txn = $self->TransactionObj;
  67 +
  68 + if ( $txn->Type eq 'Forward Transaction' ) {
  69 + my $forwarded_txn = RT::Transaction->new( $self->CurrentUser );
  70 + $forwarded_txn->Load( $txn->Field );
  71 + $self->{ForwardedTransactionObj} = $forwarded_txn;
  72 + }
  73 +
  74 + my ( $result, $message ) = $self->TemplateObj->Parse(
  75 + Argument => $self->Argument,
  76 + Ticket => $self->TicketObj,
  77 + Transaction => $self->ForwardedTransactionObj,
  78 + ForwardTransaction => $self->TransactionObj,
  79 + );
  80 +
  81 + if ( !$result ) {
  82 + return (undef);
  83 + }
  84 +
  85 + my $mime = $self->TemplateObj->MIMEObj;
  86 + $mime->make_multipart unless $mime->is_multipart;
  87 +
  88 + my $entity;
  89 + if ( $txn->Type eq 'Forward Transaction' ) {
  90 + $entity = $self->ForwardedTransactionObj->ContentAsMIME;
  91 + }
  92 + else {
  93 + my $txns = $self->TicketObj->Transactions;
  94 + $txns->Limit(
  95 + FIELD => 'Type',
  96 + VALUE => $_,
  97 + ) for qw(Create Correspond);
  98 +
  99 + $entity = MIME::Entity->build(
  100 + Type => 'multipart/mixed',
  101 + Description => 'forwarded ticket',
  102 + );
  103 + $entity->add_part($_) foreach
  104 + map $_->ContentAsMIME,
  105 + @{ $txns->ItemsArrayRef };
  106 + }
  107 +
  108 + $mime->add_part($entity);
  109 +
  110 + unless ( $mime->head->get('Subject') ) {
  111 + my $subject = '';
  112 + $subject = $self->ForwardedTransactionObj->Subject
  113 + if $self->ForwardedTransactionObj;
  114 + $subject ||= $self->TicketObj->Subject;
  115 + unless ( RT->Config->Get('ForwardFromUser') ) {
  116 + $subject =
  117 + RT::Interface::Email::AddSubjectTag( $subject, $self->TicketObj );
  118 + }
  119 + $mime->head->set( Subject => $self->MIMEEncodeString("Fwd: $subject") );
  120 + }
  121 +
  122 + my $txn_attachment = $self->TransactionObj->Attachments->First;
  123 + for my $header (qw/From To Cc Bcc/) {
  124 + if ( $txn_attachment->GetHeader( $header ) ) {
  125 + $mime->head->set( $header => $txn_attachment->GetHeader($header) );
  126 + }
  127 + }
  128 +
  129 + if ( RT->Config->Get('ForwardFromUser') ) {
  130 + $mime->head->set( 'X-RT-Sign' => 0 );
  131 + }
  132 +
  133 + $self->SUPER::Prepare();
  134 +}
  135 +
  136 +sub SetSubjectToken {
  137 +
  138 + # we already take care of this in Prepare.
  139 +}
  140 +
  141 +sub ForwardedTransactionObj {
  142 + my $self = shift;
  143 + return $self->{'ForwardedTransactionObj'};
  144 +}
  145 +
  146 +RT::Base->_ImportOverlays();
  147 +
  148 +1;
190 lib/RT/Interface/Email.pm
@@ -611,190 +611,56 @@ sub SendEmailUsingTemplate {
611 611 return SendEmail( Entity => $mail );
612 612 }
613 613
614   -=head2 ForwardTransaction TRANSACTION, To => '', Cc => '', Bcc => ''
615   -
616   -Forwards transaction with all attachments as 'message/rfc822'.
617   -
618   -=cut
619   -
620   -sub ForwardTransaction {
621   - my $txn = shift;
622   - my %args = ( To => '', Cc => '', Bcc => '', @_ );
623   -
624   - my $entity = $txn->ContentAsMIME;
625   -
626   - my ( $ret, $msg ) = SendForward( %args, Entity => $entity, Transaction => $txn );
627   - if ($ret) {
628   - my $ticket = $txn->TicketObj;
629   - my ( $ret, $msg ) = $ticket->_NewTransaction(
630   - Type => 'Forward Transaction',
631   - Field => $txn->id,
632   - Data => join ', ', grep { length } $args{To}, $args{Cc}, $args{Bcc},
633   - );
634   - unless ($ret) {
635   - $RT::Logger->error("Failed to create transaction: $msg");
636   - }
637   - }
638   - return ( $ret, $msg );
639   -}
640   -
641   -=head2 ForwardTicket TICKET, To => '', Cc => '', Bcc => ''
642   -
643   -Forwards a ticket's Create and Correspond Transactions and their Attachments as 'message/rfc822'.
644   -
645   -=cut
646   -
647   -sub ForwardTicket {
648   - my $ticket = shift;
649   - my %args = ( To => '', Cc => '', Bcc => '', @_ );
650   -
651   - my $txns = $ticket->Transactions;
652   - $txns->Limit(
653   - FIELD => 'Type',
654   - VALUE => $_,
655   - ) for qw(Create Correspond);
656   -
657   - my $entity = MIME::Entity->build(
658   - Type => 'multipart/mixed',
659   - Description => 'forwarded ticket',
660   - );
661   - $entity->add_part( $_ ) foreach
662   - map $_->ContentAsMIME,
663   - @{ $txns->ItemsArrayRef };
664   -
665   - my ( $ret, $msg ) = SendForward(
666   - %args,
667   - Entity => $entity,
668   - Ticket => $ticket,
669   - Template => 'Forward Ticket',
670   - );
671   -
672   - if ($ret) {
673   - my ( $ret, $msg ) = $ticket->_NewTransaction(
674   - Type => 'Forward Ticket',
675   - Field => $ticket->id,
676   - Data => join ', ', grep { length } $args{To}, $args{Cc}, $args{Bcc},
677   - );
678   - unless ($ret) {
679   - $RT::Logger->error("Failed to create transaction: $msg");
680   - }
681   - }
682   -
683   - return ( $ret, $msg );
684   -
685   -}
686   -
687   -=head2 SendForward Entity => undef, Ticket => undef, Transaction => undef, Template => undef, To => '', Cc => '', Bcc => ''
  614 +=head2 GetForwardFrom Ticket => undef, Transaction => undef
688 615
689   -Forwards an Entity representing Ticket or Transaction as 'message/rfc822'. Entity is wrapped into Template.
  616 +Resolve the From field to use in forward mail
690 617
691 618 =cut
692 619
693   -sub SendForward {
694   - my (%args) = (
695   - Entity => undef,
696   - Ticket => undef,
697   - Transaction => undef,
698   - Template => 'Forward',
699   - To => '', Cc => '', Bcc => '',
700   - @_
701   - );
702   -
703   - my $txn = $args{'Transaction'};
704   - my $ticket = $args{'Ticket'};
705   - $ticket ||= $txn->Object if $txn;
706   -
707   - my $entity = $args{'Entity'};
708   - unless ( $entity ) {
709   - require Carp;
710   - $RT::Logger->error(Carp::longmess("No entity provided"));
711   - return (0, $ticket->loc("Couldn't send email"));
712   - }
713   -
714   - my ($template, $msg) = PrepareEmailUsingTemplate(
715   - Template => $args{'Template'},
716   - Arguments => {
717   - Ticket => $ticket,
718   - Transaction => $txn,
719   - },
720   - );
721   -
722   - my $mail;
723   - if ( $template ) {
724   - $mail = $template->MIMEObj;
725   - } else {
726   - $RT::Logger->warning($msg);
727   - }
728   - unless ( $mail ) {
729   - $RT::Logger->warning("Couldn't generate email using template '$args{Template}'");
  620 +sub GetForwardFrom {
  621 + my %args = ( Ticket => undef, Transaction => undef, @_ );
  622 + my $txn = $args{Transaction};
  623 + my $ticket = $args{Ticket} || $txn->Object;
730 624
731   - my $description;
732   - unless ( $args{'Transaction'} ) {
733   - $description = 'This is forward of ticket #'. $ticket->id;
734   - } else {
735   - $description = 'This is forward of transaction #'
736   - . $txn->id ." of a ticket #". $txn->ObjectId;
737   - }
738   - $mail = MIME::Entity->build(
739   - Type => 'text/plain',
740   - Data => $description,
741   - );
  625 + if ( RT->Config->Get('ForwardFromUser') ) {
  626 + return ( $txn || $ticket )->CurrentUser->EmailAddress;
742 627 }
743   -
744   - $mail->head->set( $_ => EncodeToMIME( String => $args{$_} ) )
745   - foreach grep defined $args{$_}, qw(To Cc Bcc);
746   -
747   - $mail->make_multipart unless $mail->is_multipart;
748   - $mail->add_part( $entity );
749   -
750   - my $from;
751   - unless (defined $mail->head->get('Subject')) {
752   - my $subject = '';
753   - $subject = $txn->Subject if $txn;
754   - $subject ||= $ticket->Subject if $ticket;
755   -
756   - unless ( RT->Config->Get('ForwardFromUser') ) {
757   - # XXX: what if want to forward txn of other object than ticket?
758   - $subject = AddSubjectTag( $subject, $ticket );
759   - }
760   -
761   - $mail->head->set( Subject => EncodeToMIME( String => "Fwd: $subject" ) );
  628 + else {
  629 + return $ticket->QueueObj->CorrespondAddress
  630 + || RT->Config->Get('CorrespondAddress');
762 631 }
763   -
764   - $mail->head->set(
765   - From => EncodeToMIME(
766   - String => GetForwardFrom( Transaction => $txn, Ticket => $ticket )
767   - )
768   - );
769   -
770   - my $status = RT->Config->Get('ForwardFromUser')
771   - # never sign if we forward from User
772   - ? SendEmail( %args, Entity => $mail, Sign => 0 )
773   - : SendEmail( %args, Entity => $mail );
774   - return (0, $ticket->loc("Couldn't send email")) unless $status;
775   - return (1, $ticket->loc("Sent email successfully"));
776 632 }
777 633
778   -=head2 GetForwardFrom Ticket => undef, Transaction => undef
  634 +=head2 GetForwardAttachments Ticket => undef, Transaction => undef
779 635
780   -Resolve the From field to use in forward mail
  636 +Resolve the Attachments to forward
781 637
782 638 =cut
783 639
784   -sub GetForwardFrom {
  640 +sub GetForwardAttachments {
785 641 my %args = ( Ticket => undef, Transaction => undef, @_ );
786 642 my $txn = $args{Transaction};
787 643 my $ticket = $args{Ticket} || $txn->Object;
788 644
789   - if ( RT->Config->Get('ForwardFromUser') ) {
790   - return ( $txn || $ticket )->CurrentUser->EmailAddress;
  645 + my $attachments = RT::Attachments->new( $ticket->CurrentUser );
  646 + if ($txn) {
  647 + $attachments->Limit( FIELD => 'TransactionId', VALUE => $txn->id );
791 648 }
792 649 else {
793   - return $ticket->QueueObj->CorrespondAddress
794   - || RT->Config->Get('CorrespondAddress');
  650 + my $txns = $ticket->Transactions;
  651 + $txns->Limit(
  652 + FIELD => 'Type',
  653 + VALUE => $_,
  654 + ) for qw(Create Correspond);
  655 +
  656 + while ( my $txn = $txns->Next ) {
  657 + $attachments->Limit( FIELD => 'TransactionId', VALUE => $txn->id );
  658 + }
795 659 }
  660 + return $attachments;
796 661 }
797 662
  663 +
798 664 =head2 SignEncrypt Entity => undef, Sign => 0, Encrypt => 0
799 665
800 666 Signs and encrypts message using L<RT::Crypt::GnuPG>, but as well
69 lib/RT/Ticket.pm
@@ -3749,6 +3749,75 @@ sub ACLEquivalenceObjects {
3749 3749
3750 3750 }
3751 3751
  3752 +=head2 Forward Transaction => undef, To => '', Cc => '', Bcc => ''
  3753 +
  3754 +Forwards transaction with all attachments as 'message/rfc822'.
  3755 +
  3756 +=cut
  3757 +
  3758 +sub Forward {
  3759 + my $self = shift;
  3760 + my %args = (
  3761 + Transaction => undef,
  3762 + To => '',
  3763 + Cc => '',
  3764 + Bcc => '',
  3765 + Content => '',
  3766 + ContentType => 'text/plain',
  3767 + DryRun => 0,
  3768 + CommitScrips => 1,
  3769 + @_
  3770 + );
  3771 +
  3772 + unless ( $self->CurrentUserHasRight('ForwardMessage') ) {
  3773 + return ( 0, $self->loc("Permission Denied") );
  3774 + }
  3775 +
  3776 + my $mime = MIME::Entity->build(
  3777 + Type => $args{'ContentType'},
  3778 + Data => $args{Content},
  3779 + );
  3780 +
  3781 + $mime->head->set(
  3782 + $_ => RT::Interface::Email::EncodeToMIME( String => $args{$_} ) )
  3783 + for grep defined $args{$_}, qw(To Cc Bcc);
  3784 + $mime->head->set(
  3785 + From => RT::Interface::Email::EncodeToMIME(
  3786 + String => RT::Interface::Email::GetForwardFrom(
  3787 + Transaction => $args{Transaction},
  3788 + Ticket => $self,
  3789 + )
  3790 + )
  3791 + );
  3792 +
  3793 + if ($args{'DryRun'}) {
  3794 + $RT::Handle->BeginTransaction();
  3795 + $args{'CommitScrips'} = 0;
  3796 + }
  3797 +
  3798 + my ( $ret, $msg ) = $self->_NewTransaction(
  3799 + $args{Transaction}
  3800 + ? (
  3801 + Type => 'Forward Transaction',
  3802 + Field => $args{Transaction}->id,
  3803 + )
  3804 + : (
  3805 + Type => 'Forward Ticket',
  3806 + Field => $self->id,
  3807 + ),
  3808 + MIMEObj => $mime,
  3809 + CommitScrips => $args{'CommitScrips'},
  3810 + );
  3811 +
  3812 + unless ($ret) {
  3813 + $RT::Logger->error("Failed to create transaction: $msg");
  3814 + }
  3815 +
  3816 + if ($args{'DryRun'}) {
  3817 + $RT::Handle->Rollback();
  3818 + }
  3819 + return ( $ret, $self->loc('Message recorded') );
  3820 +}
3752 3821
3753 3822 1;
3754 3823
5 lib/RT/Transaction.pm
@@ -661,11 +661,10 @@ sub BriefDescription {
661 661 return $self->loc("System error");
662 662 }
663 663 elsif ( $type =~ /Forward Transaction/ ) {
664   - return $self->loc( "Forwarded Transaction #[_1] to [_2]",
665   - $self->Field, $self->Data );
  664 + return $self->loc( "Forwarded Transaction #[_1]", $self->Field );
666 665 }
667 666 elsif ( $type =~ /Forward Ticket/ ) {
668   - return $self->loc( "Forwarded Ticket to [_1]", $self->Data );
  667 + return $self->loc( "Forwarded Ticket" );
669 668 }
670 669
671 670 if ( my $code = $_BriefDescriptions{$type} ) {
23 share/html/Ticket/Forward.html
@@ -72,8 +72,21 @@
72 72 <tr><td align="right"><&|/l&>Bcc</&>:</td>
73 73 <td><input name="Bcc" size="60" value="<% $ARGS{'Bcc'} || '' %>" /></td></tr>
74 74
  75 +<tr>
  76 +<td><&|/l&>Content</&>:</td>
  77 +<td>
  78 +% if (exists $ARGS{Content}) {
  79 +<& /Elements/MessageBox, Default => $ARGS{Content}, IncludeSignature => 0 &>
  80 +% } else {
  81 +<& /Elements/MessageBox &>
  82 +%}
  83 +</td>
  84 +</tr>
  85 +
75 86 </table>
76 87
  88 +<& /Ticket/Elements/ShowAttachments, Attachments => $attachments &>
  89 +
77 90 <& /Elements/Submit, Label => loc('Forward Message and Return'), Name => 'ForwardAndReturn' &>
78 91 <& /Elements/Submit, Label => loc('Forward Message'), Name => 'Forward' &>
79 92 </form>
@@ -94,10 +107,7 @@
94 107
95 108 my @results;
96 109 if ( $Forward || $ForwardAndReturn ) {
97   - require RT::Interface::Email;
98   - my ($status, $msg) = $txn
99   - ? RT::Interface::Email::ForwardTransaction( $txn, %ARGS )
100   - : RT::Interface::Email::ForwardTicket( $TicketObj, %ARGS );
  110 + my ( $status, $msg ) = $TicketObj->Forward( Transaction => $txn, %ARGS );
101 111 push @results, $msg;
102 112
103 113 if ( $ForwardAndReturn ) {
@@ -119,6 +129,11 @@
119 129 $subject = RT::Interface::Email::AddSubjectTag( $subject, $TicketObj )
120 130 unless RT->Config->Get('ForwardFromUser');
121 131
  132 +my $attachments = RT::Interface::Email::GetForwardAttachments(
  133 + Ticket => $TicketObj,
  134 + $txn ? ( Transaction => $txn ) : (),
  135 +);
  136 +
122 137 </%INIT>
123 138
124 139 <%ARGS>
31 t/web/ticket_forward.t
@@ -37,18 +37,15 @@ diag "Forward Ticket" if $ENV{TEST_VERBOSE};
37 37 $m->submit_form(
38 38 form_name => 'ForwardMessage',
39 39 fields => {
40   - To => 'rt-test, rt-to@example.com',
  40 + To => 'rt-to@example.com',
41 41 Cc => 'rt-cc@example.com',
42 42 },
43 43 button => 'ForwardAndReturn'
44 44 );
45   - $m->content_contains( 'Sent email successfully', 'sent mail msg' );
46   - $m->content_contains(
47   - 'Forwarded Ticket to rt-test, rt-to@example.com, rt-cc@example.com',
48   - 'txn msg' );
  45 + $m->content_contains( 'Forwarded Ticket', 'txn msg' );
49 46 my ($mail) = RT::Test->fetch_caught_mails;
50 47 like( $mail, qr!Subject: test forward!, 'Subject field' );
51   - like( $mail, qr!To: rt-test, rt-to\@example.com!, 'To field' );
  48 + like( $mail, qr!To: rt-to\@example.com!, 'To field' );
52 49 like( $mail, qr!Cc: rt-cc\@example.com!, 'Cc field' );
53 50 like( $mail, qr!This is a forward of ticket!, 'content' );
54 51 like( $mail, qr!this is an attachment!, 'att content' );
@@ -61,20 +58,16 @@ diag "Forward Transaction" if $ENV{TEST_VERBOSE};
61 58 $m->submit_form(
62 59 form_name => 'ForwardMessage',
63 60 fields => {
64   - To => 'rt-test, rt-to@example.com',
  61 + To => 'rt-to@example.com',
65 62 Cc => 'rt-cc@example.com',
66 63 Bcc => 'rt-bcc@example.com'
67 64 },
68 65 button => 'ForwardAndReturn'
69 66 );
70   - $m->content_contains( 'Sent email successfully', 'sent mail msg' );
71   - $m->content_like(
72   -qr/Forwarded Transaction #\d+ to rt-test, rt-to\@example.com, rt-cc\@example.com, rt-bcc\@example.com/,
73   - 'txn msg'
74   - );
  67 + $m->content_like( qr/Forwarded Transaction #\d+/, 'txn msg' );
75 68 my ($mail) = RT::Test->fetch_caught_mails;
76 69 like( $mail, qr!Subject: test forward!, 'Subject field' );
77   - like( $mail, qr!To: rt-test, rt-to\@example.com!, 'To field' );
  70 + like( $mail, qr!To: rt-to\@example.com!, 'To field' );
78 71 like( $mail, qr!Cc: rt-cc\@example.com!, 'Cc field' );
79 72 like( $mail, qr!Bcc: rt-bcc\@example.com!, 'Bcc field' );
80 73 like( $mail, qr!This is a forward of transaction!, 'content' );
@@ -94,7 +87,6 @@ diag "Forward Ticket without content" if $ENV{TEST_VERBOSE};
94 87 fields => { To => 'rt-test@example.com', },
95 88 button => 'ForwardAndReturn'
96 89 );
97   - $m->content_contains( 'Sent email successfully', 'sent mail msg' );
98 90 my ($mail) = RT::Test->fetch_caught_mails;
99 91 like( $mail, qr/Subject: Fwd: \[example\.com #\d\] test forward without content/, 'Subject field' );
100 92 like( $mail, qr/To: rt-test\@example\.com/, 'To field' );
@@ -138,8 +130,7 @@ diag "Forward Transaction with attachments but empty content" if $ENV{TEST_VERBO
138 130 },
139 131 button => 'ForwardAndReturn'
140 132 );
141   - $m->content_contains( 'Sent email successfully', 'sent mail msg' );
142   - $m->content_like( qr/Forwarded Transaction #\d+ to rt-test\@example\.com/, 'txn msg' );
  133 + $m->content_like(qr/Forwarded Transaction #\d+/);
143 134 my ($mail) = RT::Test->fetch_caught_mails;
144 135 like( $mail, qr/Subject: test forward, empty content but attachments/, 'Subject field' );
145 136 like( $mail, qr/To: rt-test\@example.com/, 'To field' );
@@ -196,9 +187,8 @@ diag "Forward Transaction with attachments but no 'content' part" if $ENV{TEST_V
196 187 },
197 188 button => 'ForwardAndReturn'
198 189 );
199   - $m->content_contains( 'Sent email successfully', 'sent mail msg' );
200   - $m->content_like( qr/Forwarded Transaction #\d+ to rt-test\@example\.com/, 'txn msg' );
201   -
  190 + $m->content_like( qr/Forwarded Transaction #\d+/ );
  191 +
202 192 # Forward ticket
203 193 $m->follow_link_ok( { text => 'Forward', n => 1 }, 'follow 1st Forward' );
204 194 $m->submit_form(
@@ -208,8 +198,7 @@ diag "Forward Transaction with attachments but no 'content' part" if $ENV{TEST_V
208 198 },
209 199 button => 'ForwardAndReturn'
210 200 );
211   - $m->content_contains( 'Sent email successfully', 'sent mail msg' );
212   - $m->content_like( qr/Forwarded Ticket to rt-test\@example\.com/, 'txn msg' );
  201 + $m->content_like( qr/Forwarded Ticket/ );
213 202
214 203 my ($forward_txn, $forward_ticket) = RT::Test->fetch_caught_mails;
215 204 my $tag = qr/Fwd: \[example\.com #\d+\]/;

0 comments on commit ab8edd2

Please sign in to comment.
Something went wrong with that request. Please try again.