[Rt-commit] r7922 - in rt/branches/3.7-EXPERIMENTAL-TUNIS: lib/RT lib/RT/Interface t/ticket

clsung at bestpractical.com clsung at bestpractical.com
Thu May 24 04:08:13 EDT 2007


Author: clsung
Date: Thu May 24 04:08:12 2007
New Revision: 7922

Modified:
   rt/branches/3.7-EXPERIMENTAL-TUNIS/   (props changed)
   rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Email.pm
   rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/ticket/requestor-order.t

Log:
 r7484 at going04:  clsung | 2007-05-24 16:07:36 +0800
 - add mail_command() in RT::Test, thus
   - avoid sending meaningless emails to example.com
   - ability to modify mail_command() if you need something to check the mail
   - add mailsent_ok() to check if the number of sent email
 - add plan => 58 in t/ticket/requestor-order.t


Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Email.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Email.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Interface/Email.pm	Thu May 24 04:08:12 2007
@@ -369,6 +369,9 @@
 
     my $mail_command = RT->Config->Get('MailCommand');
 
+    # if it is a sub routine, we just return it;
+    return $mail_command->($args{'Entity'}) if UNIVERSAL::isa( $mail_command, 'CODE' );
+
     if ( $mail_command eq 'sendmailpipe' ) {
         my $path = RT->Config->Get('SendmailPath');
         my $args = RT->Config->Get('SendmailArguments');

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/lib/RT/Test.pm	Thu May 24 04:08:12 2007
@@ -9,6 +9,7 @@
 my $config;
 my $port;
 my $existing_server;
+my $mailsent;
 
 BEGIN {
     # TODO: allocate a port dynamically
@@ -35,6 +36,16 @@
     RT::LoadConfig;
     if (RT->Config->Get('DevelMode')) { require Module::Refresh; }
 
+    # make it another function
+    $mailsent = 0;
+    my $mailfunc = sub { 
+	my $Entity = shift;
+	$mailsent++;
+	return 1;
+    };
+    RT::Config->Set( 'MailCommand' => $mailfunc);
+
+
 };
 
 use RT::Interface::Web::Standalone;
@@ -138,4 +149,10 @@
     is ($? >> 8, 0, "The mail gateway exited normally. yay");
 }
 
+sub mailsent_ok {
+    my $class = shift;
+    my $expected  = shift;
+    is ($mailsent, $expected, "The number of mail sent ($expected) matches. yay");
+}
+
 1;

Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/ticket/requestor-order.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/ticket/requestor-order.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/ticket/requestor-order.t	Thu May 24 04:08:12 2007
@@ -1,7 +1,8 @@
 #!/usr/bin/perl -w
 use strict; use warnings;
 
-use Test::More qw/no_plan/;
+use Test::More;
+plan tests => 58;
 use_ok('RT');
 use RT::Test;
 
@@ -139,5 +140,6 @@
     is(@mails, 30, "found thirty tickets");
     is_deeply( [grep {$_} @mails], [ sort grep {$_} @mails ], "Paging works (exclude nulls, which are db-dependant)");
 }
+RT::Test->mailsent_ok(25);
 
 # vim:ft=perl:


More information about the Rt-commit mailing list