Commit | Line | Data |
c18b93ec |
1 | use strict; |
2 | use warnings; |
8b10ee55 |
3 | use Test::More tests => 13; |
c18b93ec |
4 | |
5 | use Email::Send::Test; |
6 | use FindBin; |
7 | use lib "$FindBin::Bin/lib"; |
8 | |
9 | use_ok('Catalyst::Test', 'TestApp'); |
10 | |
11 | my $response; |
8b10ee55 |
12 | my $time; |
13 | my @emails; |
14 | |
15 | $time = time; |
16 | |
c18b93ec |
17 | ok( ($response = request("/email_app_config?time=$time"))->is_success, 'request ok'); |
18 | |
8b10ee55 |
19 | @emails = Email::Send::Test->emails; |
c18b93ec |
20 | |
21 | is(@emails, 1, "got emails"); |
22 | isa_ok( $emails[0], 'Email::MIME', 'email is ok' ); |
23 | like($emails[0]->body, qr/$time/, 'Got our email'); |
8b10ee55 |
24 | |
25 | Email::Send::Test->clear; |
26 | |
27 | $time = time; |
28 | ok( ($response = request("/template_email_app_config?time=$time"))->is_success, 'request ok'); |
29 | |
30 | @emails = Email::Send::Test->emails; |
31 | |
32 | is(@emails, 1, "got emails"); |
33 | isa_ok( $emails[0], 'Email::MIME', 'email is ok' ); |
34 | my @parts = $emails[0]->parts; |
35 | cmp_ok(@parts, '==', 2, 'got parts'); |
36 | |
28151039 |
37 | is($parts[0]->content_type, 'text/plain', 'text/plain ok'); |
8b10ee55 |
38 | like($parts[0]->body, qr/test-email\@example.com on $time/, 'got content back'); |
28151039 |
39 | is($parts[1]->content_type, 'text/html', 'text/html ok'); |
8b10ee55 |
40 | like($parts[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back'); |
41 | |