[Rt-commit] r8936 - in rt/branches/3.7-EXPERIMENTAL: lib/RT
ruz at bestpractical.com
ruz at bestpractical.com
Wed Sep 5 09:50:04 EDT 2007
Author: ruz
Date: Wed Sep 5 09:50:03 2007
New Revision: 8936
Modified:
rt/branches/3.7-EXPERIMENTAL/lib/RT/Test.pm
rt/branches/3.7-EXPERIMENTAL/t/web/crypt-gnupg.t
Log:
* add mail catcher
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Test.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Test.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Test.pm Wed Sep 5 09:50:03 2007
@@ -397,6 +397,27 @@
return ($status, $id);
}
+sub set_mail_catcher {
+ my $self = shift;
+ my $catcher = sub {
+ my $MIME = shift;
+
+ open my $handle, '>>', 't/mailbox'
+ or die "Unable to open t/mailbox for appending: $!";
+
+ $MIME->print($handle);
+ print $handle "%% split me! %%\n";
+ close $handle;
+ };
+ RT->Config->Set( MailCommand => $catcher );
+}
+
+sub fetch_caught_mails {
+ my $self = shift;
+ return grep /\S/, split /%% split me! %%/,
+ RT::Test->file_content( 't/mailbox', 'unlink' => 1 );
+}
+
sub file_content {
my $self = shift;
my $path = shift;
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 Wed Sep 5 09:50:03 2007
@@ -10,22 +10,12 @@
# catch any outgoing emails
unlink "t/mailbox";
-sub capture_mail {
- my $MIME = shift;
-
- open my $handle, '>>', 't/mailbox'
- or die "Unable to open t/mailbox for appending: $!";
-
- $MIME->print($handle);
- print $handle "%% split me! %%\n";
- close $handle;
-}
+RT::Test->set_mail_catcher;
RT->Config->Set( LogToScreen => 'debug' );
RT->Config->Set( LogStackTraces => 'error' );
RT->Config->Set( CommentAddress => 'general at example.com');
RT->Config->Set( CorrespondAddress => 'general at example.com');
-RT->Config->Set( MailCommand => \&capture_mail);
RT->Config->Set( DefaultSearchResultFormat => qq{
'<B><A HREF="__WebPath__/Ticket/Display.html?id=__id__">__id__</a></B>/TITLE:#',
'<B><A HREF="__WebPath__/Ticket/Display.html?id=__id__">__Subject__</a></B>/TITLE:Subject',
@@ -87,8 +77,7 @@
$m->get($baseurl); # ensure that the mail has been processed
-my $mails = RT::Test->file_content( 't/mailbox', 'unlink' => 1 );
-my @mail = grep {/\S/} split /%% split me! %%/, $mails;
+my @mail = RT::Test->fetch_caught_mails;
ok(@mail, "got some mail");
$user->SetEmailAddress('general at example.com');
@@ -162,8 +151,7 @@
$m->get($baseurl); # ensure that the mail has been processed
-$mails = RT::Test->file_content( 't/mailbox', 'unlink' => 1 );
- at mail = grep {/\S/} split /%% split me! %%/, $mails;
+ at mail = RT::Test->fetch_caught_mails;
ok(@mail, "got some mail");
for my $mail (@mail) {
like $mail, qr/Some other content/, "outgoing mail was not encrypted";
@@ -240,8 +228,7 @@
$m->get($baseurl); # ensure that the mail has been processed
-$mails = RT::Test->file_content( 't/mailbox', 'unlink' => 1 );
- at mail = grep {/\S/} split /%% split me! %%/, $mails;
+ at mail = RT::Test->fetch_caught_mails;
ok(@mail, "got some mail");
for my $mail (@mail) {
unlike $mail, qr/Some other content/, "outgoing mail was encrypted";
@@ -312,8 +299,7 @@
$m->get($baseurl); # ensure that the mail has been processed
-$mails = RT::Test->file_content( 't/mailbox', 'unlink' => 1 );
- at mail = grep {/\S/} split /%% split me! %%/, $mails;
+ at mail = RT::Test->fetch_caught_mails;
ok(@mail, "got some mail");
for my $mail (@mail) {
like $mail, qr/Thought you had me figured out didya/, "outgoing mail was unencrypted";
More information about the Rt-commit
mailing list