diff options
Diffstat (limited to 't/app/helpers')
-rw-r--r-- | t/app/helpers/emails/html_test.html | 15 | ||||
-rw-r--r-- | t/app/helpers/emails/html_test.txt | 14 | ||||
-rw-r--r-- | t/app/helpers/emails/test.txt | 14 | ||||
-rw-r--r-- | t/app/helpers/send_email.t | 32 |
4 files changed, 70 insertions, 5 deletions
diff --git a/t/app/helpers/emails/html_test.html b/t/app/helpers/emails/html_test.html new file mode 100644 index 000000000..49f7b38d3 --- /dev/null +++ b/t/app/helpers/emails/html_test.html @@ -0,0 +1,15 @@ +Subject: test email ☺ + +Hello, + +This is a test email where foo: [% foo %]. + +utf8: 我们应该能够无缝处理UTF8编码 + + indented_text + +It additionally has an inline image! +<img src="[% inline_image('t/app/helpers/grey.gif') %]"> + +Yours, +FixMyStreet. diff --git a/t/app/helpers/emails/html_test.txt b/t/app/helpers/emails/html_test.txt new file mode 100644 index 000000000..692d25ccf --- /dev/null +++ b/t/app/helpers/emails/html_test.txt @@ -0,0 +1,14 @@ +Subject: test email ☺ + +Hello, + +This is a test email where foo: [% foo %]. + +utf8: 我们应该能够无缝处理UTF8编码 + + indented_text + +It additionally has an inline image! + +Yours, +FixMyStreet. diff --git a/t/app/helpers/emails/test.txt b/t/app/helpers/emails/test.txt new file mode 100644 index 000000000..1acd4b6ca --- /dev/null +++ b/t/app/helpers/emails/test.txt @@ -0,0 +1,14 @@ +Subject: test email ☺ + +Hello, + +This is a test email where foo: [% foo %]. + +utf8: 我们应该能够无缝处理UTF8编码 + + indented_text + +long line: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + +Yours, +FixMyStreet. diff --git a/t/app/helpers/send_email.t b/t/app/helpers/send_email.t index e2c8688a8..3975002fa 100644 --- a/t/app/helpers/send_email.t +++ b/t/app/helpers/send_email.t @@ -2,6 +2,12 @@ use strict; use warnings; use utf8; +package FixMyStreet::Cobrand::Tester; +use parent 'FixMyStreet::Cobrand::Default'; +sub path_to_email_templates { [ FixMyStreet->path_to( 't', 'app', 'helpers', 'emails') ] } + +package main; + BEGIN { use FixMyStreet; FixMyStreet->test_mode(1); @@ -28,8 +34,12 @@ $c->stash->{foo} = 'bar'; Email::Send::Test->clear; # send the test email -ok $c->send_email( 'test.txt', { to => 'test@recipient.com' } ), - "sent an email"; +FixMyStreet::override_config { + ALLOWED_COBRANDS => [ 'tester' ], +}, sub { + ok $c->send_email( 'test.txt', { to => 'test@recipient.com' } ), + "sent an email"; +}; # check it got templated and sent correctly my @emails = Email::Send::Test->emails; @@ -51,9 +61,7 @@ is_string $email->body, $expected_email->body, 'email is as expected'; subtest 'MIME attachments' => sub { my $data = path(__FILE__)->parent->child('grey.gif')->slurp_raw; - Email::Send::Test->clear; - my @emails = Email::Send::Test->emails; - is scalar(@emails), 0, "reset"; + $mech->clear_emails_ok; ok $c->send_email( 'test.txt', { to => 'test@recipient.com', @@ -108,6 +116,20 @@ subtest 'MIME attachments' => sub { $path->spew($email_as_string); diag "Saved output in $path"; }; + $mech->clear_emails_ok; +}; + +subtest 'Inline emails!' => sub { + ok $c->send_email( 'html_test.txt', { to => 'test@recipient.com' } ), "sent an email with email attachments"; + + my $email = $mech->get_email; + like $email->debug_structure, qr[ + \+\ multipart/related.*\n + \ {5}\+\ multipart/alternative.*\n + \ {10}\+\ text/plain.*\n + \ {10}\+\ text/html.*\n + \ {5}\+\ image/gif]x; + $mech->clear_emails_ok; }; done_testing; |