diff options
Diffstat (limited to 't/app/helpers/send_email.t')
-rw-r--r-- | t/app/helpers/send_email.t | 48 |
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 + |