Fix for RT#32215 ticket for multipart not coming through
[catagits/Catalyst-View-Email.git] / t / lib / TestApp / Controller / Root.pm
index 737018e..bff9d20 100644 (file)
@@ -31,23 +31,84 @@ sub email : Global('email') {
     }
 }
 
+sub email_app_config : Global('email_app_config') {
+    my ($self, $c, @args) = @_;
+
+    my $time = $c->req->params->{time} || time;
+
+    $c->stash->{email} = {
+        to      => 'test-email@example.com',
+        from    => 'no-reply@example.com',
+        subject => 'Email Test',
+        body    => "Email Sent at: $time"
+    };
+
+    $c->forward('TestApp::View::Email::AppConfig');
+
+    if ( scalar( @{ $c->error } ) ) {
+        $c->res->status(500);
+        $c->res->body('Email Failed');
+    } else {
+        $c->res->body('Plain Email Ok');
+    }
+}
+
 sub template_email : Global('template_email') {
     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 => [
+            {
+                template        => 'text_plain/test.tt',
+                content_type    => 'text/plain',
+            },
+            {
+                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_app_config : Global('template_email_app_config') {
+    my ($self, $c, @args) = @_;
+
+    $c->stash->{time} = $c->req->params->{time} || time;
+
+    $c->stash->{template_email} = {
         to      => 'test-email@example.com',
         from    => 'no-reply@example.com',
         subject => 'Just a test',
-        content_type => 'multipart/alternative',
         templates => [
-            qw{text_plain/test.tt},
-            qw{text_html/test.tt}
-        ]
+            {
+                template        => 'text_plain/test.tt',
+                content_type    => 'text/plain',
+            },
+            {
+                view            => 'TT',
+                template        => 'text_html/test.tt',
+                content_type    => 'text/html',
+            },
+        ],
     };
 
-    $c->forward('TestApp::View::Email::Template');    
+    $c->forward('TestApp::View::Email::Template::AppConfig');
 
     if ( scalar( @{ $c->error } ) ) {
         $c->res->status(500);
@@ -57,4 +118,38 @@ sub template_email : Global('template_email') {
     }
 }
 
+sub mason_email : Global('mason_email') {
+    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',
+        view    => 'Mason',
+        templates => [
+            {
+                template        => 'text_plain/test.m',
+                content_type    => 'text/plain',
+            },
+            {
+                view            => 'Mason',
+                template        => 'text_html/test.m',
+                content_type    => 'text/html',
+            },
+        ],
+    };
+
+    $c->forward('TestApp::View::Email::Template');    
+
+    if ( scalar( @{ $c->error } ) ) {
+        $c->res->status(500);
+        $c->res->body('Mason Email Failed');
+    } else {
+        $c->res->body('Mason Email Ok');
+    }
+}
+
+
 1;