aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/helpers/send_email.t
diff options
context:
space:
mode:
authorEdmund von der Burg <evdb@mysociety.org>2011-03-02 13:55:37 +0000
committerEdmund von der Burg <evdb@mysociety.org>2011-03-02 13:55:37 +0000
commit90395716d892de1d1134a7d0e68866e699c19406 (patch)
tree9fe5e0b1247ad1f6c0da774ea17fc225667b87b8 /t/app/helpers/send_email.t
parentc5a4a6e496f4aebd496336c44a61c0b1c64dfccd (diff)
Simple email sending
Diffstat (limited to 't/app/helpers/send_email.t')
-rw-r--r--t/app/helpers/send_email.t48
1 files changed, 48 insertions, 0 deletions
diff --git a/t/app/helpers/send_email.t b/t/app/helpers/send_email.t
new file mode 100644
index 000000000..6a7d77c0b
--- /dev/null
+++ b/t/app/helpers/send_email.t
@@ -0,0 +1,48 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+BEGIN {
+ use FixMyStreet;
+ FixMyStreet->test_mode(1);
+}
+
+use Test::More tests => 4;
+
+use Email::Send::Test;
+
+use_ok 'FixMyStreet::App';
+my $c = FixMyStreet::App->new;
+
+# fake up the request a little
+$c->req->uri( URI->new('http://localhost/') );
+$c->req->base( $c->req->uri );
+
+
+# set some values in the stash
+$c->stash->{foo} = 'bar';
+
+# clear the email queue
+Email::Send::Test->clear;
+
+# send the test email
+ok $c->send_email( 'test', { to => 'test@recipient.com' } ), "sent an email";
+
+# check it got templated and sent correctly
+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
+
+Hello,
+
+This is a test email where foo: bar.
+
+Yours,
+ FixMyStreet.
+END_OF_BODY
+