diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-03-31 14:17:54 +0100 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2016-03-31 14:17:54 +0100 |
commit | dac0d4c71018c01d858d0111d0f772b49a6e124d (patch) | |
tree | 191bb55f2ebb738d8fccb8b3e73db5688aff291a /t/cobrand | |
parent | 6702f44f92e9c74fe6d2dd1c69c5418a15af178c (diff) | |
parent | e4707406bd816fb9b1bb2077b7452cc77dec3d94 (diff) |
Merge remote-tracking branch 'mysociety/refactor-email'
Diffstat (limited to 't/cobrand')
-rw-r--r-- | t/cobrand/fixamingata.t | 8 | ||||
-rw-r--r-- | t/cobrand/zurich.t | 7 | ||||
-rw-r--r-- | t/cobrand/zurich_attachments.txt | 73 |
3 files changed, 43 insertions, 45 deletions
diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t index 50b7713d1..0cf7a31fe 100644 --- a/t/cobrand/fixamingata.t +++ b/t/cobrand/fixamingata.t @@ -46,10 +46,10 @@ FixMyStreet::override_config { FixMyStreet::DB->resultset('Problem')->send_reports(); }; my $email = $mech->get_email; -like $email->header('Content-Type'), qr/iso-8859-1/, 'encoding looks okay'; +like $email->header('Content-Type'), qr/utf-8/, 'encoding looks okay'; like $email->header('Subject'), qr/Ny rapport: Test Test/, 'subject looks okay'; like $email->header('To'), qr/other\@example.org/, 'to line looks correct'; -like $email->body, qr/V=E4nligen,/, 'signature looks correct'; +like $email->body_str, qr/V\xe4nligen,/, 'signature looks correct'; $mech->clear_emails_ok; my $user = @@ -91,8 +91,8 @@ FixMyStreet::override_config { $mech->email_count_is(1); $email = $mech->get_email; -like $email->header('Content-Type'), qr/iso-8859-1/, 'encoding looks okay'; -like $email->body, qr/V=E4nligen,/, 'signature looks correct'; +like $email->header('Content-Type'), qr/utf-8/, 'encoding looks okay'; +like $email->body_str, qr/V\xe4nligen,/, 'signature looks correct'; $mech->clear_emails_ok; subtest "Test ajax decimal points" => sub { diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t index 4734dc837..cf66136e5 100644 --- a/t/cobrand/zurich.t +++ b/t/cobrand/zurich.t @@ -661,7 +661,7 @@ subtest "external report triggers email" => sub { }; $email = $mech->get_email; my $report_id = $report->id; - like $email->header('Subject'), qr/Meldung #$report_id/, 'subject looks okay'; + like Encode::decode('MIME-Header', $email->header('Subject')), qr/Meldung #$report_id/, 'subject looks okay'; like $email->header('To'), qr/test\@example.com/, 'to line looks correct'; like $email->body, qr/$PUBLIC_RESPONSE/, 'public_response was passed on' or die $email->body; $mech->clear_emails_ok; @@ -894,6 +894,11 @@ subtest 'email images to external partners' => sub { my $expected_email_content = path(__FILE__)->parent->child('zurich_attachments.txt')->slurp; my $REPORT_ID = $report->id; + $expected_email_content =~ s{Subject: (.*?)\r?\n}{ + my $subj = Encode::decode('MIME-Header', $1); + $subj =~ s{REPORT_ID}{$REPORT_ID}g; + 'Subject: ' . Email::MIME::Encode::mime_encode($subj, "utf-8") . "\n"; + }eg; $expected_email_content =~ s{REPORT_ID}{$REPORT_ID}g; $expected_email_content =~ s{BOUNDARY}{$boundary}g; my $expected_email = Email::MIME->new($expected_email_content); diff --git a/t/cobrand/zurich_attachments.txt b/t/cobrand/zurich_attachments.txt index 4ccc90205..bdc4333bf 100644 --- a/t/cobrand/zurich_attachments.txt +++ b/t/cobrand/zurich_attachments.txt @@ -1,40 +1,33 @@ -MIME-Version: 1.0 -Subject: =?iso-8859-1?Q?Z=FCri?= wie neu: Weitergeleitete Meldung #REPORT_ID -Content-Type: multipart/mixed; boundary="BOUNDARY" -To: "External Body" <external_body@example.org> -Content-Transfer-Encoding: 7bit -From: FixMyStreet <division@example.org> - - ---BOUNDARY -MIME-Version: 1.0 -Subject: =?iso-8859-1?Q?Z=FCri?= wie neu: Weitergeleitete Meldung #REPORT_ID -Content-Type: text/plain; charset="iso-8859-1" -To: "External Body" <external_body@example.org> -Content-Transfer-Encoding: quoted-printable -From: FixMyStreet <division@example.org> - -Gr=FCezi External Body, - -=D6ffentliche URL: http://www.example.org/report/REPORT_ID - -Bei Fragen zu "Z=FCri wie neu" wenden Sie sich bitte an -gis-zentrum@zuerich.ch.= - - - ---BOUNDARY -MIME-Version: 1.0 -Content-Type: image/jpeg; name="REPORT_ID.0.jpeg" -Content-Disposition: inline; filename="REPORT_ID.0.jpeg" -Content-Transfer-Encoding: base64 - -/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEP -ERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4e -Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCABTAAEDAREA -AhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAIIB//EAB8QAQAABAcAAAAAAAAAAAAAAAADBAbT -BxcYVVaUpf/EABcBAQEBAQAAAAAAAAAAAAAAAAAFBgT/xAAgEQEAAAQHAQAAAAAAAAAAAAAAAwQV -UgECFlNhodGx/9oADAMBAAIRAxEAPwCywAIozyxS5R58tbbujSW33j6zFRj3fGbKbjAGAgAACs9N -FCbtUfYg2mO1BM25e/V+lQeW3ISo/9k= - ---BOUNDARY-- +MIME-Version: 1.0
+Subject: =?iso-8859-1?Q?Z=FCri?= wie neu: Weitergeleitete Meldung #REPORT_ID
+Content-Type: multipart/mixed; boundary="BOUNDARY"
+To: "External Body" <external_body@example.org>
+Content-Transfer-Encoding: 7bit
+From: "FixMyStreet" <division@example.org>
+
+
+--BOUNDARY
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: quoted-printable
+
+Gr=C3=BCezi External Body,
+
+=C3=96ffentliche URL: http://www.example.org/report/REPORT_ID
+
+Bei Fragen zu "Z=C3=BCri wie neu" wenden Sie sich bitte an
+gis-zentrum@zuerich.ch.=
+
+--BOUNDARY
+Content-Type: image/jpeg; name="REPORT_ID.0.jpeg"
+Content-Disposition: inline; filename="REPORT_ID.0.jpeg"
+Content-Transfer-Encoding: base64
+
+/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEP
+ERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4e
+Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/wAARCABTAAEDAREA
+AhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAIIB//EAB8QAQAABAcAAAAAAAAAAAAAAAADBAbT
+BxcYVVaUpf/EABcBAQEBAQAAAAAAAAAAAAAAAAAFBgT/xAAgEQEAAAQHAQAAAAAAAAAAAAAAAwQV
+UgECFlNhodGx/9oADAMBAAIRAxEAPwCywAIozyxS5R58tbbujSW33j6zFRj3fGbKbjAGAgAACs9N
+FCbtUfYg2mO1BM25e/V+lQeW3ISo/9k=
+
+--BOUNDARY--
|