aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perllib/FixMyStreet/App.pm6
-rw-r--r--perllib/FixMyStreet/App/Controller/Alert.pm10
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm16
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/Update.pm6
-rwxr-xr-xt/Page.t31
-rw-r--r--t/app/helpers/send_email.t19
-rw-r--r--t/templates/mysite/test-header1
-rw-r--r--templates/web/default/email_sent.html13
8 files changed, 35 insertions, 67 deletions
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index 10e0dbb28..ec7ec3ff0 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -275,9 +275,13 @@ sub send_email {
my $template = shift;
my $extra_stash_values = shift || {};
+ my $sender = $c->cobrand->contact_email;
+ my $sender_name = $c->cobrand->contact_name;
+ $sender =~ s/team/fms-DO-NOT-REPLY/;
+
# create the vars to pass to the email template
my $vars = {
- from => FixMyStreet->config('CONTACT_EMAIL'),
+ from => [ $sender, _($sender_name) ],
%{ $c->stash },
%$extra_stash_values,
additional_template_paths => [
diff --git a/perllib/FixMyStreet/App/Controller/Alert.pm b/perllib/FixMyStreet/App/Controller/Alert.pm
index b5258ae79..e7eab09b8 100644
--- a/perllib/FixMyStreet/App/Controller/Alert.pm
+++ b/perllib/FixMyStreet/App/Controller/Alert.pm
@@ -301,15 +301,7 @@ sub send_confirmation_email : Private {
$c->stash->{token_url} = $c->uri_for_email( '/A', $token->token );
- my $sender = mySociety::Config::get('CONTACT_EMAIL');
-
- $c->send_email(
- 'alert-confirm.txt',
- {
- to => $c->stash->{alert}->user->email,
- from => $sender
- }
- );
+ $c->send_email( 'alert-confirm.txt', { to => $c->stash->{alert}->user->email } );
$c->stash->{template} = 'email_sent.html';
}
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 1d08de29d..3e71cb0bd 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -251,17 +251,7 @@ sub report_import : Path('/import') {
$c->stash->{report} = $report;
$c->stash->{token_url} = $c->uri_for_email( '/L', $token->token );
- my $sender = mySociety::Config::get('CONTACT_EMAIL');
- $sender =~ s/team/fms-DO-NOT-REPLY/;
-
- # TODO - used to be sent using EvEl
- $c->send_email(
- 'partial.txt',
- {
- to => $report->user->email,
- from => $sender
- }
- );
+ $c->send_email( 'partial.txt', { to => $report->user->email, } );
$c->res->body('SUCCESS');
return 1;
@@ -945,7 +935,9 @@ sub redirect_or_confirm_creation : Private {
$c->model("DB::Token")
->create( { scope => 'problem', data => $report->id } );
$c->stash->{token_url} = $c->uri_for_email( '/P', $token->token );
- $c->send_email( 'problem-confirm.txt', { to => $report->user->email } );
+ $c->send_email( 'problem-confirm.txt', {
+ to => [ [ $report->user->email, $report->name ] ],
+ } );
# tell user that they've been sent an email
$c->stash->{template} = 'email_sent.html';
diff --git a/perllib/FixMyStreet/App/Controller/Report/Update.pm b/perllib/FixMyStreet/App/Controller/Report/Update.pm
index e0a7033b9..fe512d03c 100644
--- a/perllib/FixMyStreet/App/Controller/Report/Update.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/Update.pm
@@ -292,7 +292,11 @@ sub redirect_or_confirm_creation : Private {
}
);
$c->stash->{token_url} = $c->uri_for_email( '/C', $token->token );
- $c->send_email( 'update-confirm.txt', { to => $update->user->email } );
+ $c->send_email( 'update-confirm.txt', {
+ to => $update->name
+ ? [ [ $update->user->email, $update->name ] ]
+ : $update->user->email,
+ } );
# tell user that they've been sent an email
$c->stash->{template} = 'email_sent.html';
diff --git a/t/Page.t b/t/Page.t
index 5e55b8e1f..9331d4ef9 100755
--- a/t/Page.t
+++ b/t/Page.t
@@ -11,7 +11,7 @@
use strict;
use warnings;
-use Test::More tests => 8;
+use Test::More tests => 4;
use Test::Exception;
use FindBin;
@@ -36,33 +36,6 @@ sub set_lang($) {
mySociety::Locale::change();
}
-sub test_header() {
- my $q = mock_query();
- my $html;
- my %params = (title => 'test title');
- set_lang('en-gb,English,en_GB');
-
- # Test that param that isn't explicitly allowed raises error
- $params{'test-param'} = 'test';
- throws_ok { Page::header($q, %params); } qr/bad parameter/, 'bad parameter caught ok';
- delete $params{'test-param'};
-
- # Test that template passed is rendered
- $params{'template'} = 'test';
- $html = Page::template_include('test-header', $q,
- '/../t/templates/' . $q->{site} . '/',
- title => 'My test title', lang => 'en-gb'
- );
-
- like ($html, qr/My test header template/, 'named template rendered ok');
-
- return 1;
-}
-
-sub test_footer(){
- return 1;
-}
-
sub test_base_url_with_lang {
set_lang('en-gb,English,en_GB');
my $q = mock_query();
@@ -80,5 +53,3 @@ sub test_base_url_with_lang {
ok(test_base_url_with_lang() == 1, 'Ran all tests for base_url_with_lang');
-ok(test_footer() == 1, 'Ran all tests for the footer function');
-ok(test_header() == 1, 'Ran all tests for the header function');
diff --git a/t/app/helpers/send_email.t b/t/app/helpers/send_email.t
index 2e90b9f1a..5ab84e017 100644
--- a/t/app/helpers/send_email.t
+++ b/t/app/helpers/send_email.t
@@ -15,11 +15,17 @@ use Email::Send::Test;
use Path::Class;
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 );
+my $c = FixMyStreet::App->new(
+ {
+ request => Catalyst::Request->new(
+ {
+ base => URI->new('http://fixmystreet.com/'),
+ uri => URI->new('http://fixmystreet.com/')
+ }
+ ),
+ }
+);
+$c->setup_request();
# set some values in the stash
$c->stash->{foo} = 'bar';
@@ -40,7 +46,8 @@ my $email_as_string = $emails[0]->as_string;
ok $email_as_string =~ s{\s+Date:\s+\S.*?$}{}xms, "Found and stripped out date";
my $expected_email_content = file(__FILE__)->dir->file('send_email_sample.txt')->slurp;
-$expected_email_content =~ s{CONTACT_EMAIL}{ FixMyStreet->config('CONTACT_EMAIL') }e;
+my $sender = '"' . FixMyStreet->config('CONTACT_NAME') . '" <' . FixMyStreet->config('CONTACT_EMAIL') . '>';
+$expected_email_content =~ s{CONTACT_EMAIL}{$sender};
is $email_as_string,
$expected_email_content,
diff --git a/t/templates/mysite/test-header b/t/templates/mysite/test-header
deleted file mode 100644
index 83d959d3d..000000000
--- a/t/templates/mysite/test-header
+++ /dev/null
@@ -1 +0,0 @@
-My test header template
diff --git a/templates/web/default/email_sent.html b/templates/web/default/email_sent.html
index a20900524..47a6f82cf 100644
--- a/templates/web/default/email_sent.html
+++ b/templates/web/default/email_sent.html
@@ -21,15 +21,14 @@
}
%]
-<h1>Nearly Done! Now check your email...</h1>
+<h1>[% loc("Nearly Done! Now check your email...") %]</h1>
-<p>The confirmation email <strong>may</strong> take a few minutes to arrive &mdash; <em>please</em> be patient.</p>
+<p>[% loc("The confirmation email <strong>may</strong> take a few minutes to arrive &mdash; <em>please</em> be patient.") %]</p>
-<p>If you use web-based email or have 'junk mail' filters, you may wish to check your bulk/spam mail folders: sometimes, our messages are marked that way.</p>
+<p>[% loc("If you use web-based email or have 'junk mail' filters, you may wish to check your bulk/spam mail folders: sometimes, our messages are marked that way.") %]</p>
-<p>You must now click the link in the email we've just sent you &mdash; if you do not, [% messages.$email_type.action %].</p>
+<p>[% tprintf( loc("You must now click the link in the email we've just sent you &mdash; if you do not, %s."), messages.$email_type.action ) %].</p>
-<p>(Don't worry &mdash; [% messages.$email_type.worry %])</p>
+<p>[% tprintf( loc("(Don't worry &mdash; %s)"), messages.$email_type.worry ) %]</p>
-
-[% INCLUDE 'footer.html' %] \ No newline at end of file
+[% INCLUDE 'footer.html' %]