Fix for RT#32215 ticket for multipart not coming through
[catagits/Catalyst-View-Email.git] / t / lib / TestApp / Controller / Root.pm
CommitLineData
82300460 1package # Hide from PAUSE
2 TestApp::Controller::Root;
3
4use base qw(Catalyst::Controller);
5
6sub default : Private {
7 my ( $self, $c ) = @_;
8
9 $c->res->body(qq{Nothing Here});
10}
11
12sub email : Global('email') {
13 my ($self, $c, @args) = @_;
14
15 my $time = $c->req->params->{time} || time;
16
17 $c->stash->{email} = {
fd0033bc 18 to => 'test-email@example.com',
19 from => 'no-reply@example.com',
82300460 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
25650747 34sub 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
82300460 56sub 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} = {
ab4326b4 62 to => 'test-email@example.com',
63 from => 'no-reply@example.com',
64 subject => 'Just a test',
65 content_type => 'multipart/alternative',
82300460 66 templates => [
06afcdbc 67 {
06afcdbc 68 template => 'text_plain/test.tt',
69 content_type => 'text/plain',
70 },
71 {
72 view => 'TT',
73 template => 'text_html/test.tt',
74 content_type => 'text/html',
75 },
76 ],
82300460 77 };
78
79 $c->forward('TestApp::View::Email::Template');
80
81 if ( scalar( @{ $c->error } ) ) {
82 $c->res->status(500);
83 $c->res->body('Template Email Failed');
84 } else {
85 $c->res->body('Template Email Ok');
86 }
87}
88
8b10ee55 89sub template_email_app_config : Global('template_email_app_config') {
90 my ($self, $c, @args) = @_;
91
92 $c->stash->{time} = $c->req->params->{time} || time;
93
94 $c->stash->{template_email} = {
95 to => 'test-email@example.com',
96 from => 'no-reply@example.com',
97 subject => 'Just a test',
8b10ee55 98 templates => [
06afcdbc 99 {
100 template => 'text_plain/test.tt',
101 content_type => 'text/plain',
102 },
103 {
ea115f9b 104 view => 'TT',
06afcdbc 105 template => 'text_html/test.tt',
106 content_type => 'text/html',
107 },
108 ],
8b10ee55 109 };
110
111 $c->forward('TestApp::View::Email::Template::AppConfig');
112
113 if ( scalar( @{ $c->error } ) ) {
114 $c->res->status(500);
115 $c->res->body('Template Email Failed');
116 } else {
117 $c->res->body('Template Email Ok');
118 }
119}
120
121sub mason_email : Global('mason_email') {
122 my ($self, $c, @args) = @_;
123
124 $c->stash->{time} = $c->req->params->{time} || time;
125
126 $c->stash->{email} = {
127 to => 'test-email@example.com',
128 from => 'no-reply@example.com',
129 subject => 'Just a test',
43090696 130 view => 'Mason',
8b10ee55 131 templates => [
06afcdbc 132 {
c649c40e 133 template => 'text_plain/test.m',
06afcdbc 134 content_type => 'text/plain',
135 },
136 {
ea115f9b 137 view => 'Mason',
c649c40e 138 template => 'text_html/test.m',
06afcdbc 139 content_type => 'text/html',
140 },
141 ],
8b10ee55 142 };
143
144 $c->forward('TestApp::View::Email::Template');
145
146 if ( scalar( @{ $c->error } ) ) {
147 $c->res->status(500);
148 $c->res->body('Mason Email Failed');
149 } else {
150 $c->res->body('Mason Email Ok');
151 }
152}
153
154
82300460 1551;