added test for patch added by https://rt.cpan.org/Ticket/Display.html?id=66495
Devin Austin [Tue, 15 Jan 2013 21:49:41 +0000 (14:49 -0700)]
t/05template.t
t/lib/TestApp/Controller/Root.pm

index 9855fb2..79e316e 100644 (file)
@@ -13,6 +13,7 @@ use lib "$FindBin::Bin/lib";
 use_ok('Catalyst::Test', 'TestApp');
 
 my $response;
+my $response2;
 my $time = time;
 ok( ( $response = request("/template_email?time=$time"))->is_success,
     'request ok' );
@@ -32,4 +33,12 @@ like($parts[0]->body, qr/test-email\@example.com on $time/, 'got content back');
 is($parts[1]->content_type, 'text/html', 'text/html ok');
 like($parts[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back');
 #like($emails[0]->body, qr/$time/, 'Got our email');
+
+ok( ( $response2 = request("/template_email_single?time=$time"))->is_success,
+    'request ok' );
+like( $response2->content, qr/Template Email Ok/, 'controller says ok' );
+my @emails2 = Email::Sender::Simple->default_transport->deliveries;
+my @parts2 = $emails2[0]->{'email'}[0]->parts;
+is($parts2[1]->content_type, 'text/html', 'text/html ok');
+like($parts2[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back');
 done_testing();
index b23019e..fc1e89a 100644 (file)
@@ -88,6 +88,34 @@ sub template_email : Global('template_email') {
     }
 }
 
+sub template_email_single : Global('template_email_single') {
+    my ($self, $c, @args) = @_;
+
+    $c->stash->{time} = $c->req->params->{time} || time;
+
+    $c->stash->{email} = {
+        to           => 'test-email@example.com',
+        from         => 'no-reply@example.com',
+        subject      => 'Just a test',
+        content_type => 'multipart/alternative',
+        templates =>  {
+            view            => 'TT',
+            template        => 'text_html/test.tt',
+            content_type    => 'text/html',
+        },
+        
+    };
+
+    $c->forward('TestApp::View::Email::Template');    
+
+    if ( scalar( @{ $c->error } ) ) {
+        $c->res->status(500);
+        $c->res->body('Template Email Failed');
+    } else {
+        $c->res->body('Template Email Ok');
+    }
+}
+
 sub template_email_utf8 : Global('template_email_utf8') {
     my ($self, $c, @args) = @_;