[Rt-commit] r5803 - in RT-Extension-CommandByEmail: . t

kevinr at bestpractical.com kevinr at bestpractical.com
Wed Aug 23 18:44:17 EDT 2006


Author: kevinr
Date: Wed Aug 23 18:44:17 2006
New Revision: 5803

Modified:
   RT-Extension-CommandByEmail/   (props changed)
   RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm
   RT-Extension-CommandByEmail/t/02.create.t

Log:
 r27524 at sad-girl-in-snow:  kevinr | 2006-08-23 13:42:53 -0400
 * Fixed the handling of multiple TimeWorked headers on create


Modified: RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm
==============================================================================
--- RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm	(original)
+++ RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm	Wed Aug 23 18:44:17 2006
@@ -430,6 +430,13 @@
                 $cmds{ lc $attribute } = $user->Name if $user->id;
             }
 
+            if ( $attribute eq 'TimeWorked' && ref $cmds{ lc $attribute } ) {
+                my $time_taken = 0;
+                map { $time_taken += ($_ || 0) }  @{ $cmds{'timeworked'} };
+                $cmds{'timeworked'} = $time_taken;
+                $RT::Logger->debug("Time taken on create: $time_taken");
+            }
+
             $create_args{$attribute} = $cmds{ lc $attribute };
         }
         foreach my $attribute (@DATE_ATTRIBUTES) {

Modified: RT-Extension-CommandByEmail/t/02.create.t
==============================================================================
--- RT-Extension-CommandByEmail/t/02.create.t	(original)
+++ RT-Extension-CommandByEmail/t/02.create.t	Wed Aug 23 18:44:17 2006
@@ -133,6 +133,26 @@
 }
 
 
+diag("handle multiple time worked statements") if $ENV{'TEST_VERBOSE'};
+{
+    my $text = <<END;
+Subject: multiple TimeWorked test
+From: root\@localhost
+
+TimeWorked: 5
+TimeWorked: 5
+
+test
+END
+    my $id = create_ticket_via_gate( $text );
+    ok($id, "created ticket");
+    my $obj = RT::Ticket->new( $RT::SystemUser );
+    $obj->Load( $id );
+    is($obj->id, $id, "loaded ticket");
+    is($obj->TimeWorked, 10, 'set time' );
+}
+
+
 diag("set watchers on create") if $ENV{'TEST_VERBOSE'};
 foreach my $field ( qw(Requestor Cc AdminCc) ) {
     my $value = 'test at localhost';


More information about the Rt-commit mailing list