[Rt-commit] r8699 - in rt/branches/3.7-EXPERIMENTAL-TUNIS: t/web

sartak at bestpractical.com sartak at bestpractical.com
Thu Aug 23 12:53:17 EDT 2007


Author: sartak
Date: Thu Aug 23 12:53:16 2007
New Revision: 8699

Modified:
   rt/branches/3.7-EXPERIMENTAL-TUNIS/   (props changed)
   rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/crypt-gnupg.t

Log:
 r38011 at gorgoroth:  sartak | 2007-08-23 12:51:37 -0400
 Handle outgoing mail better (that is, at all)


Modified: rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/crypt-gnupg.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/crypt-gnupg.t	(original)
+++ rt/branches/3.7-EXPERIMENTAL-TUNIS/t/web/crypt-gnupg.t	Thu Aug 23 12:53:16 2007
@@ -1,12 +1,30 @@
 #!/usr/bin/perl -w
 use strict;
 
-use Test::More tests => 11;
+use Test::More tests => 14;
 use RT::Test;
 use RT::Action::SendEmail;
 
 eval 'use GnuPG::Interface; 1' or plan skip_all => 'GnuPG required.';
 
+# catch any outgoing emails
+unlink "t/mailbox";
+
+is (__PACKAGE__, 'main', "We're operating in the main package");
+{
+    no warnings qw/redefine/;
+    sub RT::Action::SendEmail::SendMessage {
+        my $self = shift;
+        my $MIME = shift;
+
+        open my $handle, '>>', 't/mailbox'
+            or die "Unable to open t/mailbox for appending: $!";
+
+        print $handle map {"$_\n"} @{$MIME->body};
+        print $handle "%% split me! %%\n";
+    }
+}
+
 RT->Config->Set( LogToScreen => 'debug' );
 RT->Config->Set( LogStackTraces => 'error' );
 
@@ -26,19 +44,6 @@
                  passphrase => 'rt-test',
                  'no-permission-warning' => undef);
 
-# catch any outgoing emails
-our @outgoing;
-is (__PACKAGE__, 'main', "We're operating in the main package");
-{
-    no warnings qw/redefine/;
-    sub RT::Action::SendEmail::SendMessage {
-        my $self = shift;
-        my $MIME = shift;
-
-        main::unlike($MIME->body, qr/Some content/, "content was encrypted");
-    }
-}
-
 ok(my $user = RT::User->new($RT::SystemUser));
 ok($user->Load('root'), "Loaded user 'root'");
 $user->SetEmailAddress('recipient at example.com');
@@ -72,4 +77,21 @@
 $m->submit;
 is($m->status, 200, "request successful");
 
-$m->get("$baseurl"); # make sure the server has handled all mail
+$m->get($baseurl); # ensure that the mail has been processed
+
+my $mail = file_content('t/mailbox');
+my @mail = split /\n%% split me! %%\n/, $mail;
+pop @mail;
+ok(@mail, "got some mail");
+for (@mail) {
+    unlike $_, qr/Some content/, "outgoing mail was encrypted";
+}
+
+sub file_content
+{
+    my $path = shift;
+    diag "reading content of '$path'" if $ENV{'TEST_VERBOSE'};
+    open my $fh, "<:raw", $path or die "couldn't open file '$path': $!";
+    local $/;
+    return scalar <$fh>;
+}


More information about the Rt-commit mailing list