Bump to v0.06, adding in Mason tests and better config handling
[catagits/Catalyst-View-Email.git] / t / lib / TestApp / Controller / Root.pm
1 package  # Hide from PAUSE
2     TestApp::Controller::Root;
3
4 use base qw(Catalyst::Controller);
5
6 sub default : Private {
7     my ( $self, $c ) = @_;
8
9     $c->res->body(qq{Nothing Here});
10 }
11
12 sub email : Global('email') {
13     my ($self, $c, @args) = @_;
14
15     my $time = $c->req->params->{time} || time;
16
17     $c->stash->{email} = {
18         to      => 'test-email@example.com',
19         from    => 'no-reply@example.com',
20         subject => 'Email Test',
21         body    => "Email Sent at: $time"
22     };
23
24     $c->forward('TestApp::View::Email');
25
26     if ( scalar( @{ $c->error } ) ) {
27         $c->res->status(500);
28         $c->res->body('Email Failed');
29     } else {
30         $c->res->body('Plain Email Ok');
31     }
32 }
33
34 sub email_app_config : Global('email_app_config') {
35     my ($self, $c, @args) = @_;
36
37     my $time = $c->req->params->{time} || time;
38
39     $c->stash->{email} = {
40         to      => 'test-email@example.com',
41         from    => 'no-reply@example.com',
42         subject => 'Email Test',
43         body    => "Email Sent at: $time"
44     };
45
46     $c->forward('TestApp::View::Email::AppConfig');
47
48     if ( scalar( @{ $c->error } ) ) {
49         $c->res->status(500);
50         $c->res->body('Email Failed');
51     } else {
52         $c->res->body('Plain Email Ok');
53     }
54 }
55
56 sub template_email : Global('template_email') {
57     my ($self, $c, @args) = @_;
58
59     $c->stash->{time} = $c->req->params->{time} || time;
60
61     $c->stash->{email} = {
62         to      => 'test-email@example.com',
63         from    => 'no-reply@example.com',
64         subject => 'Just a test',
65         content_type => 'multipart/alternative',
66         templates => [
67             qw{text_plain/test.tt},
68             qw{text_html/test.tt}
69         ]
70     };
71
72     $c->forward('TestApp::View::Email::Template');    
73
74     if ( scalar( @{ $c->error } ) ) {
75         $c->res->status(500);
76         $c->res->body('Template Email Failed');
77     } else {
78         $c->res->body('Template Email Ok');
79     }
80 }
81
82 sub template_email_app_config : Global('template_email_app_config') {
83     my ($self, $c, @args) = @_;
84
85     $c->stash->{time} = $c->req->params->{time} || time;
86
87     $c->stash->{template_email} = {
88         to      => 'test-email@example.com',
89         from    => 'no-reply@example.com',
90         subject => 'Just a test',
91         content_type => 'multipart/alternative',
92         templates => [
93             qw{text_plain/test.tt},
94             qw{text_html/test.tt}
95         ]
96     };
97
98     $c->forward('TestApp::View::Email::Template::AppConfig');
99
100     if ( scalar( @{ $c->error } ) ) {
101         $c->res->status(500);
102         $c->res->body('Template Email Failed');
103     } else {
104         $c->res->body('Template Email Ok');
105     }
106 }
107
108 sub mason_email : Global('mason_email') {
109     my ($self, $c, @args) = @_;
110
111     $c->stash->{time} = $c->req->params->{time} || time;
112
113     $c->stash->{email} = {
114         to      => 'test-email@example.com',
115         from    => 'no-reply@example.com',
116         subject => 'Just a test',
117         content_type => 'multipart/alternative',
118         templates => [
119             qw{text_plain/test.m},
120             qw{text_html/test.m}
121         ]
122     };
123
124     $c->forward('TestApp::View::Email::Template');    
125
126     if ( scalar( @{ $c->error } ) ) {
127         $c->res->status(500);
128         $c->res->body('Mason Email Failed');
129     } else {
130         $c->res->body('Mason Email Ok');
131     }
132 }
133
134
135 1;