[Rt-commit] r8780 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Tue Aug 28 14:41:01 EDT 2007
Author: ruz
Date: Tue Aug 28 14:41:01 2007
New Revision: 8780
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/t/web/crypt-gnupg.t
Log:
r8700 at cubic-pc (orig r8699): sartak | 2007-08-23 20:53:16 +0400
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/t/web/crypt-gnupg.t
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/t/web/crypt-gnupg.t (original)
+++ rt/branches/3.7-EXPERIMENTAL/t/web/crypt-gnupg.t Tue Aug 28 14:41:01 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