aboutsummaryrefslogtreecommitdiffstats
path: root/t/app
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-03-31 14:17:54 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-03-31 14:17:54 +0100
commitdac0d4c71018c01d858d0111d0f772b49a6e124d (patch)
tree191bb55f2ebb738d8fccb8b3e73db5688aff291a /t/app
parent6702f44f92e9c74fe6d2dd1c69c5418a15af178c (diff)
parente4707406bd816fb9b1bb2077b7452cc77dec3d94 (diff)
Merge remote-tracking branch 'mysociety/refactor-email'
Diffstat (limited to 't/app')
-rw-r--r--t/app/01app.t4
-rw-r--r--t/app/controller/questionnaire.t10
-rw-r--r--t/app/helpers/send_email.t3
-rw-r--r--t/app/helpers/send_email_sample.txt4
-rw-r--r--t/app/helpers/send_email_sample_mime.txt106
-rw-r--r--t/app/model/alert_type.t2
6 files changed, 61 insertions, 68 deletions
diff --git a/t/app/01app.t b/t/app/01app.t
index eb98b6319..df562b829 100644
--- a/t/app/01app.t
+++ b/t/app/01app.t
@@ -16,12 +16,16 @@ use Encode qw(encode);
ok( request('/')->is_success, 'Request should succeed' );
+SKIP: {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'tester' ],
}, sub {
+ skip 'Test will not pass on Mac OS', 1 if $^O eq 'darwin';
+
my $page = get('/');
my $num = encode('UTF-8', "12\N{NO-BREAK SPACE}345");
like $page, qr/$num/;
};
+}
done_testing();
diff --git a/t/app/controller/questionnaire.t b/t/app/controller/questionnaire.t
index 7718d5034..cad86a40d 100644
--- a/t/app/controller/questionnaire.t
+++ b/t/app/controller/questionnaire.t
@@ -63,8 +63,8 @@ my $email = $mech->get_email;
ok $email, "got an email";
like $email->body, qr/fill in our short questionnaire/i, "got questionnaire email";
-like $email->body, qr/Testing =96 Detail/, 'email contains encoded character';
-is $email->header('Content-Type'), 'text/plain; charset="windows-1252"', 'in the right character set';
+like $email->body_str, qr/Testing \x{2013} Detail/, 'email contains encoded character';
+is $email->header('Content-Type'), 'text/plain; charset="utf-8"', 'in the right character set';
my ($token) = $email->body =~ m{http://.*?/Q/(\S+)};
ok $token, "extracted questionnaire token '$token'";
@@ -461,9 +461,9 @@ FixMyStreet::override_config {
ok $email, "got an email";
$mech->clear_emails_ok;
- like $email->body, qr/Testing =96 Detail/, 'email contains encoded character from user';
- like $email->body, qr/sak p=E5 FiksGataMi/, 'email contains encoded character from template';
- is $email->header('Content-Type'), 'text/plain; charset="windows-1252"', 'email is in right encoding';
+ like $email->body_str, qr/Testing \x{2013} Detail/, 'email contains encoded character from user';
+ like $email->body_str, qr/sak p\xe5 FiksGataMi/, 'email contains encoded character from template';
+ is $email->header('Content-Type'), 'text/plain; charset="utf-8"', 'email is in right encoding';
};
$mech->delete_user('test@example.com');
diff --git a/t/app/helpers/send_email.t b/t/app/helpers/send_email.t
index f60f7fa5a..e2c8688a8 100644
--- a/t/app/helpers/send_email.t
+++ b/t/app/helpers/send_email.t
@@ -41,8 +41,7 @@ my $email = Email::MIME->new($email_as_string);
my $expected_email_content = path(__FILE__)->parent->child('send_email_sample.txt')->slurp;
my $name = FixMyStreet->config('CONTACT_NAME');
-$name = "\"$name\"" if $name =~ / /;
-my $sender = $name . ' <' . FixMyStreet->config('DO_NOT_REPLY_EMAIL') . '>';
+my $sender = '"' . $name . '" <' . FixMyStreet->config('DO_NOT_REPLY_EMAIL') . '>';
$expected_email_content =~ s{CONTACT_EMAIL}{$sender};
my $expected_email = Email::MIME->new($expected_email_content);
diff --git a/t/app/helpers/send_email_sample.txt b/t/app/helpers/send_email_sample.txt
index 1ccce6a23..0f7406172 100644
--- a/t/app/helpers/send_email_sample.txt
+++ b/t/app/helpers/send_email_sample.txt
@@ -1,5 +1,5 @@
MIME-Version: 1.0
-Subject: test email =?utf-8?Q?=E2=98=BA?=
+Subject: =?UTF-8?B?dGVzdCBlbWFpbCDimLo=?=
Content-Type: text/plain; charset="utf-8"
To: test@recipient.com
Content-Transfer-Encoding: quoted-printable
@@ -24,5 +24,3 @@ culpa qui officia deserunt mollit anim id est laborum.
Yours,=20=20
FixMyStreet.=20=
-
-
diff --git a/t/app/helpers/send_email_sample_mime.txt b/t/app/helpers/send_email_sample_mime.txt
index c4ca97bcc..0649d1ceb 100644
--- a/t/app/helpers/send_email_sample_mime.txt
+++ b/t/app/helpers/send_email_sample_mime.txt
@@ -1,57 +1,49 @@
-MIME-Version: 1.0
-Subject: test email =?utf-8?Q?=E2=98=BA?=
-Content-Type: multipart/mixed; boundary="BOUNDARY"
-To: test@recipient.com
-Content-Transfer-Encoding: 7bit
-From: CONTACT_EMAIL
-
-
---BOUNDARY
-MIME-Version: 1.0
-Subject: test email =?utf-8?Q?=E2=98=BA?=
-Content-Type: text/plain; charset="utf-8"
-To: test@recipient.com
-Content-Transfer-Encoding: quoted-printable
-From: CONTACT_EMAIL
-
-Hello,
-
-This is a test email where foo: bar.
-
-utf8: =E6=88=91=E4=BB=AC=E5=BA=94=E8=AF=A5=E8=83=BD=E5=A4=9F=E6=97=A0=E7=BC=
-=9D=E5=A4=84=E7=90=86UTF8=E7=BC=96=E7=A0=81
-
- 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,=20=20
-FixMyStreet.=20=
-
-
-
---BOUNDARY
-MIME-Version: 1.0
-Content-Type: image/gif; name="foo.gif"
-Content-Disposition: inline; filename="foo.gif"
-Content-Transfer-Encoding: quoted-printable
-
-GIF89a=01=00=01=00=80=00=00=00=00=00=CC=CC=CC,=00=00=00=00=01=00=01=00=00=
-=02=01L=00;=
-
---BOUNDARY
-MIME-Version: 1.0
-Content-Type: image/gif; name="bar.gif"
-Content-Disposition: inline; filename="bar.gif"
-Content-Transfer-Encoding: quoted-printable
-
-GIF89a=01=00=01=00=80=00=00=00=00=00=CC=CC=CC,=00=00=00=00=01=00=01=00=00=
-=02=01L=00;=
-
---BOUNDARY--
+MIME-Version: 1.0
+Subject: =?UTF-8?B?dGVzdCBlbWFpbCDimLo=?=
+Content-Type: multipart/mixed; boundary="BOUNDARY"
+To: test@recipient.com
+Content-Transfer-Encoding: 7bit
+From: CONTACT_EMAIL
+
+
+--BOUNDARY
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: quoted-printable
+
+Hello,
+
+This is a test email where foo: bar.
+
+utf8: =E6=88=91=E4=BB=AC=E5=BA=94=E8=AF=A5=E8=83=BD=E5=A4=9F=E6=97=A0=E7=BC=
+=9D=E5=A4=84=E7=90=86UTF8=E7=BC=96=E7=A0=81
+
+ 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,=20=20
+FixMyStreet.=20=
+
+--BOUNDARY
+Content-Type: image/gif; name="foo.gif"
+Content-Disposition: inline; filename="foo.gif"
+Content-Transfer-Encoding: quoted-printable
+
+GIF89a=01=00=01=00=80=00=00=00=00=00=CC=CC=CC,=00=00=00=00=01=00=01=00=00=
+=02=01L=00;=
+
+--BOUNDARY
+Content-Type: image/gif; name="bar.gif"
+Content-Disposition: inline; filename="bar.gif"
+Content-Transfer-Encoding: quoted-printable
+
+GIF89a=01=00=01=00=80=00=00=00=00=00=CC=CC=CC,=00=00=00=00=01=00=01=00=00=
+=02=01L=00;=
+
+--BOUNDARY--
diff --git a/t/app/model/alert_type.t b/t/app/model/alert_type.t
index 0130f404e..e94ee8ce1 100644
--- a/t/app/model/alert_type.t
+++ b/t/app/model/alert_type.t
@@ -287,7 +287,7 @@ foreach my $test (
desc => 'address only',
addressLine => '18 North Bridge',
locality => undef,
- nearest => qr/: 18 North Bridge\n/,
+ nearest => qr/: 18 North Bridge\r?\n/,
},
{
desc => 'no fields',