diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-07-15 18:31:52 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2016-08-01 11:52:22 +0100 |
commit | 1820db45188fd62699223f63167c5f7250d1b7a6 (patch) | |
tree | 116814d9bb6ebd7f6fa015d3e492993b620ac6b1 /t/app/controller/report_new.t | |
parent | 0271c3fa016178f8c72b1192f1d0ed57437ec4c4 (diff) |
Add HTML email templates.
Design is all Zarino. This adds the ability to send HTML emails,
including attached inline images. When included, this is done as a
multipart/related email containing a multipart/alternative (of plain and
HTML) and any attached images, so that the images are available even if
HTML mail is not.
The alert emails list data has been improved so it can be constructed in
the templates rather than the code. Various templates have been tidied.
Various workarounds for email clients have been made, including:
* <th> is used so that the Android 4.x mail client can give them
`block` styling in the small screen media query.
* Font settings defined on every table cell (<th>) so that sans-serif
fonts are used in Outlook, rather than Times New Roman.
* A three-column wrapper table to create a 620px centred content area
that also shrinks down on narrow screens. (Outlook doesn’t like
max-width, so this is the simplest alternative.)
* Enforcing a sensible (500px) min-width for the main content area,
on clients that don’t support media queries (eg: native Gmail app).
* Giant borders on buttons so Outlook displays them
* Image alignment with align rather than float.
Diffstat (limited to 't/app/controller/report_new.t')
-rw-r--r-- | t/app/controller/report_new.t | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 2aebfa00b..6b4f40172 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -607,10 +607,9 @@ foreach my $test ( # receive token my $email = $mech->get_email; ok $email, "got an email"; - like $email->body, qr/confirm that you want to send your\s+report/i, "confirm the problem"; + like $mech->get_text_body_from_email($email), qr/confirm that you want to send your\s+report/i, "confirm the problem"; - my ($url) = $email->body =~ m{(http://\S+)}; - ok $url, "extracted confirm url '$url'"; + my $url = $mech->get_link_from_email($email); # confirm token $mech->get_ok($url); @@ -949,10 +948,9 @@ subtest "test report creation for a category that is non public" => sub { my $email = $mech->get_email; ok $email, "got an email"; - like $email->body, qr/confirm that you want to send your\s+report/i, "confirm the problem"; + like $mech->get_text_body_from_email($email), qr/confirm that you want to send your\s+report/i, "confirm the problem"; - my ($url) = $email->body =~ m{(http://\S+)}; - ok $url, "extracted confirm url '$url'"; + my $url = $mech->get_link_from_email($email); # confirm token $mech->get_ok($url); @@ -1145,10 +1143,9 @@ for my $test ( my $email = $mech->get_email; ok $email, "got an email"; - like $email->body, qr/confirm that you want to send your\s+report/i, "confirm the problem"; + like $mech->get_text_body_from_email($email), qr/confirm that you want to send your\s+report/i, "confirm the problem"; - my ($url) = $email->body =~ m{(https?://\S+)}; - ok $url, "extracted confirm url '$url'"; + my $url = $mech->get_link_from_email($email); # confirm token in order to update the user details $mech->get_ok($url); @@ -1315,17 +1312,17 @@ subtest "test Hart" => sub { # receive token my $email = $mech->get_email; ok $email, "got an email"; - like $email->body, qr/to confirm that you want to send your/i, "confirm the problem"; + my $body = $mech->get_text_body_from_email($email); + like $body, qr/to confirm that you want to send your/i, "confirm the problem"; # does it reference the fact that this report hasn't been sent to Hart? if ( $test->{national} ) { - like $email->body, qr/Hart Council is not responsible for this type/i, "mentions report hasn't gone to Hart"; + like $body, qr/Hart Council is not responsible for this type/i, "mentions report hasn't gone to Hart"; } else { - unlike $email->body, qr/Hart Council is not responsible for this type/i, "doesn't mention report hasn't gone to Hart"; + unlike $body, qr/Hart Council is not responsible for this type/i, "doesn't mention report hasn't gone to Hart"; } - my ($url) = $email->body =~ m{(http://\S+)}; - ok $url, "extracted confirm url '$url'"; + my $url = $mech->get_link_from_email($email); # confirm token FixMyStreet::override_config { @@ -1541,9 +1538,7 @@ subtest "unresponsive body handling works" => sub { ok $report, "Found the report"; is $report->bodies_str, undef, "Report not going anywhere"; - my $email = $mech->get_email; - ok $email, "got an email"; - like $email->body, qr/despite not being sent/i, "correct email sent"; + like $mech->get_text_body_from_email, qr/despite not being sent/i, "correct email sent"; $user->problems->delete; $mech->clear_emails_ok; @@ -1577,9 +1572,7 @@ subtest "unresponsive body handling works" => sub { ok $report, "Found the report"; is $report->bodies_str, undef, "Report not going anywhere"; - $email = $mech->get_email; - ok $email, "got an email"; - like $email->body, qr/despite not being sent/i, "correct email sent"; + like $mech->get_text_body_from_email, qr/despite not being sent/i, "correct email sent"; $user->problems->delete; $mech->clear_emails_ok; @@ -1737,10 +1730,9 @@ subtest "extra google analytics code displayed on email confirmation problem cre my $email = $mech->get_email; ok $email, "got an email"; - like $email->body, qr/confirm that you want to/i, "confirm the problem"; + like $mech->get_text_body_from_email($email), qr/confirm that you want to/i, "confirm the problem"; - my ($url) = $email->body =~ m{(https?://\S+)}; - ok $url, "extracted confirm url '$url'"; + my $url = $mech->get_link_from_email($email); # confirm token in order to update the user details $mech->get_ok($url); |