aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/model/problem.t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-07-15 18:31:52 +0100
committerDave Arter <davea@mysociety.org>2016-08-01 11:52:22 +0100
commit1820db45188fd62699223f63167c5f7250d1b7a6 (patch)
tree116814d9bb6ebd7f6fa015d3e492993b620ac6b1 /t/app/model/problem.t
parent0271c3fa016178f8c72b1192f1d0ed57437ec4c4 (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/model/problem.t')
-rw-r--r--t/app/model/problem.t27
1 files changed, 15 insertions, 12 deletions
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index ea45f7356..836e8a047 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -548,24 +548,25 @@ foreach my $test ( {
like $email->header('To'), $test->{ to }, 'to line looks correct';
is $email->header('From'), sprintf('"%s" <%s>', $test->{ name }, $test->{ email } ), 'from line looks correct';
like $email->header('Subject'), qr/A Title/, 'subject line looks correct';
- like $email->body, qr/A user of FixMyStreet/, 'email body looks a bit like a report';
- like $email->body, qr/Subject: A Title/, 'more email body checking';
- like $email->body, $test->{ dear }, 'Salutation looks correct';
+ my $body = $mech->get_text_body_from_email($email);
+ like $body, qr/A user of FixMyStreet/, 'email body looks a bit like a report';
+ like $body, qr/Subject: A Title/, 'more email body checking';
+ like $body, $test->{ dear }, 'Salutation looks correct';
if ($test->{longitude}) {
- like $email->body, qr{Easting/Northing \(IE\): 297279/362371};
+ like $body, qr{Easting/Northing \(IE\): 297279/362371};
} else {
- like $email->body, qr{Easting/Northing: };
+ like $body, qr{Easting/Northing: };
}
if ( $test->{multiple} ) {
- like $email->body, qr/This email has been sent to several councils /, 'multiple body text correct';
+ like $body, qr/This email has been sent to several councils /, 'multiple body text correct';
} elsif ( $test->{ missing } ) {
- like $email->body, $test->{ missing }, 'missing body information correct';
+ like $body, $test->{ missing }, 'missing body information correct';
}
if ( $test->{url} ) {
my $id = $problem->id;
- like $email->body, qr[$test->{url}fixmystreet.com/report/$id], 'URL present is correct';
+ like $body, qr[$test->{url}fixmystreet.com/report/$id], 'URL present is correct';
}
$problem->discard_changes;
@@ -655,16 +656,18 @@ subtest 'check can turn on report sent email alerts' => sub {
like $email->header('To'),qr/City of Edinburgh Council/, 'to line looks correct';
is $email->header('From'), '"Test User" <system_user@example.com>', 'from line looks correct';
like $email->header('Subject'), qr/A Title/, 'subject line looks correct';
- like $email->body, qr/A user of FixMyStreet/, 'email body looks a bit like a report';
- like $email->body, qr/Subject: A Title/, 'more email body checking';
- like $email->body, qr/Dear City of Edinburgh Council/, 'Salutation looks correct';
+ my $body = $mech->get_text_body_from_email($email);
+ like $body, qr/A user of FixMyStreet/, 'email body looks a bit like a report';
+ like $body, qr/Subject: A Title/, 'more email body checking';
+ like $body, qr/Dear City of Edinburgh Council/, 'Salutation looks correct';
$problem->discard_changes;
ok defined( $problem->whensent ), 'whensent set';
$email = $emails[1];
like $email->header('Subject'), qr/FixMyStreet Report Sent/, 'report sent email title correct';
- like $email->body, qr/to submit your report/, 'report sent body correct';
+ $body = $mech->get_text_body_from_email($email);
+ like $body, qr/to submit your report/, 'report sent body correct';
$send_confirmation_mail_override->restore();
};