aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/helpers
diff options
context:
space:
mode:
authorEdmund von der Burg <evdb@mysociety.org>2011-03-03 11:39:57 +0000
committerEdmund von der Burg <evdb@mysociety.org>2011-03-03 11:39:57 +0000
commitaa0d7a595c6e442ac2ef50e7041070d42d2c26e7 (patch)
tree4804186b76938fae006597724380c43e4005ca10 /t/app/helpers
parentc47cfe2bdd85b1561b57a5bccad9a1512af1f1bb (diff)
Change emails to use construct_email from mySociety::Email for encoding and line wrapping
Diffstat (limited to 't/app/helpers')
-rw-r--r--t/app/helpers/send_email.t24
-rw-r--r--t/app/helpers/send_email_sample.txt29
2 files changed, 37 insertions, 16 deletions
diff --git a/t/app/helpers/send_email.t b/t/app/helpers/send_email.t
index a44ddb01c..16e85b4ce 100644
--- a/t/app/helpers/send_email.t
+++ b/t/app/helpers/send_email.t
@@ -9,9 +9,10 @@ BEGIN {
FixMyStreet->test_mode(1);
}
-use Test::More tests => 4;
+use Test::More tests => 5;
use Email::Send::Test;
+use Path::Class;
use_ok 'FixMyStreet::App';
my $c = FixMyStreet::App->new;
@@ -20,7 +21,6 @@ my $c = FixMyStreet::App->new;
$c->req->uri( URI->new('http://localhost/') );
$c->req->base( $c->req->uri );
-
# set some values in the stash
$c->stash->{foo} = 'bar';
@@ -34,19 +34,11 @@ ok $c->send_email( 'test', { to => 'test@recipient.com' } ), "sent an email";
my @emails = Email::Send::Test->emails;
is scalar(@emails), 1, "caught one email";
-is $emails[0]->as_string, << 'END_OF_BODY', "email is as expected";
-Subject: test email
-From: evdb@ecclestoad.co.uk
-To: test@recipient.com
-Content-Type: text/plain; charset="utf-8"
-
-Hello,
-
-This is a test email where foo: bar.
-
-utf8: 我们应该能够无缝处理UTF8编码
+# Get the email, check it has a date and then strip it out
+my $email_as_string = $emails[0]->as_string;
+ok $email_as_string =~ s{\s+Date:\s+\S.*?$}{}xms, "Found and stripped out date";
-Yours,
- FixMyStreet.
-END_OF_BODY
+is $email_as_string,
+ file(__FILE__)->dir->file('send_email_sample.txt')->slurp,
+ "email is as expected";
diff --git a/t/app/helpers/send_email_sample.txt b/t/app/helpers/send_email_sample.txt
new file mode 100644
index 000000000..c6bdac74f
--- /dev/null
+++ b/t/app/helpers/send_email_sample.txt
@@ -0,0 +1,29 @@
+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: evdb@ecclestoad.co.uk
+
+ 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,
+ FixMyStreet.
+
+