[Rt-commit] r17143 - in rt/3.8/branches/ruleset: t/approval

clkao at bestpractical.com clkao at bestpractical.com
Sun Dec 7 11:12:50 EST 2008


Author: clkao
Date: Sun Dec  7 11:12:50 2008
New Revision: 17143

Modified:
   rt/3.8/branches/ruleset/lib/RT/Approval/Rule/NewPending.pm
   rt/3.8/branches/ruleset/t/approval/basic.t

Log:
improve newpending notification to include the content of the approval
ticket we created from the workflow template.


Modified: rt/3.8/branches/ruleset/lib/RT/Approval/Rule/NewPending.pm
==============================================================================
--- rt/3.8/branches/ruleset/lib/RT/Approval/Rule/NewPending.pm	(original)
+++ rt/3.8/branches/ruleset/lib/RT/Approval/Rule/NewPending.pm	Sun Dec  7 11:12:50 2008
@@ -15,7 +15,35 @@
 
 sub Commit {
     my $self = shift;
+    my ($top) = $self->TicketObj->AllDependedOnBy( Type => 'ticket' );
+    my $t = $self->TicketObj->Transactions;
+    my $to;
+    while ( my $o = $t->Next ) {
+        $to = $o, last if $o->Type eq 'Create';
+    }
+
+    # XXX: this makes the owner incorrect so notify owner won't work
+    # local $self->{TicketObj} = $top;
+
+    # first txn entry of the approval ticket
+    local $self->{TransactionObj} = $to;
     $self->RunScripAction('Notify Owner', 'New Pending Approval', @_);
+
+    return;
+
+    # this generates more correct content of the message, but not sure
+    # if ccmessageto is the right way to do this.
+    my $template = RT::Template->new($self->CurrentUser);
+    $template->Load('New Pending Approval')
+        or die;
+
+    my ( $result, $msg ) = $template->Parse(
+        TicketObj => $top,
+        TransactionObj => $to,
+    );
+    $self->TicketObj->Comment( CcMessageTo => $self->TicketObj->OwnerObj->EmailAddress,
+                               MIMEObj => $template->MIMEObj );
+
 }
 
 1;

Modified: rt/3.8/branches/ruleset/t/approval/basic.t
==============================================================================
--- rt/3.8/branches/ruleset/t/approval/basic.t	(original)
+++ rt/3.8/branches/ruleset/t/approval/basic.t	Sun Dec  7 11:12:50 2008
@@ -111,7 +111,7 @@
 } { from => qr/RT System/,
     to => 'cfo at company.com',
     subject => qr/New Pending Approval: CFO Approval/,
-    body => qr/pending your approval/
+    body => qr/pending your approval.*Your approval is requested.*Blah/s
 };
 
 my $deps = $t->DependsOn;
@@ -149,7 +149,7 @@
 } { from => qr/RT System/,
     to => 'ceo at company.com',
     subject => qr/New Pending Approval: PO approval request for PO/,
-    body => qr/pending your approval/
+    body => qr/pending your approval.*CFO approved.*ok with that\?/s
 },{ from => qr/RT System/,
     to => 'minion at company.com',
     subject => qr/Ticket Approved:/,


More information about the Rt-commit mailing list