aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/helpers/send_email.t
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/send_email.t
parentc47cfe2bdd85b1561b57a5bccad9a1512af1f1bb (diff)
Change emails to use construct_email from mySociety::Email for encoding and line wrapping
Diffstat (limited to 't/app/helpers/send_email.t')
-rw-r--r--t/app/helpers/send_email.t24
1 files changed, 8 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";