aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2015-09-25 18:03:58 +0100
committerMatthew Somerville <matthew@mysociety.org>2015-09-28 15:33:22 +0100
commit101cfc70b05960cd0fdd40580e0f45563ea7b58f (patch)
tree39cfae7a527297b6d50e63a271ba504af8b6f312
parent99610f11646c3b8530dfdb19e08b11650569b9f6 (diff)
Send altered confirmation email if not being sent.
Fixes #1210.
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm5
-rw-r--r--t/app/controller/report_new.t11
-rw-r--r--templates/email/default/problem-confirm-not-sending.txt32
3 files changed, 46 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index de9f33105..d5b84815b 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -1149,6 +1149,9 @@ sub redirect_or_confirm_creation : Private {
return 1;
}
+ my $template = 'problem-confirm.txt';
+ $template = 'problem-confirm-not-sending.txt' unless $report->bodies_str;
+
# otherwise create a confirm token and email it to them.
my $data = $c->stash->{token_data} || {};
my $token = $c->model("DB::Token")->create( {
@@ -1159,7 +1162,7 @@ sub redirect_or_confirm_creation : Private {
}
} );
$c->stash->{token_url} = $c->uri_for_email( '/P', $token->token );
- $c->send_email( 'problem-confirm.txt', {
+ $c->send_email( $template, {
to => [ $report->name ? [ $report->user->email, $report->name ] : $report->user->email ],
} );
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t
index bd0001be8..3c05adfbd 100644
--- a/t/app/controller/report_new.t
+++ b/t/app/controller/report_new.t
@@ -1475,7 +1475,7 @@ subtest "unresponsive body handling works" => sub {
ok $mech->content_like( qr{Edinburgh.*accept reports.*/unresponsive\?body=$body_id} );
my $test_email = 'test-2@example.com';
- my $user = $mech->log_in_ok($test_email);
+ $mech->log_out_ok;
$mech->get_ok('/around');
$mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } }, "submit location" );
$mech->follow_link_ok( { text_regex => qr/skip this step/i, }, "follow 'skip this step' link" );
@@ -1486,6 +1486,7 @@ subtest "unresponsive body handling works" => sub {
detail => 'Test report details.',
photo => '',
name => 'Joe Bloggs',
+ email => $test_email,
may_show_name => '1',
phone => '07903 123 456',
category => 'Trees',
@@ -1494,10 +1495,17 @@ subtest "unresponsive body handling works" => sub {
"submit good details"
);
+ my $user = FixMyStreet::App->model('DB::User')->find( { email => $test_email } );
+ ok $user, "test user does exist";
+
my $report = $user->problems->first;
ok $report, "Found the report";
is $report->bodies_str, undef, "Report not going anywhere";
+ my $email = $mech->get_email;
+ ok $email, "got an email";
+ like $email->body, qr/despite not being sent/i, "correct email sent";
+
$user->problems->delete;
$contact1->body->update( { send_method => $old_send } );
@@ -1517,6 +1525,7 @@ subtest "unresponsive body handling works" => sub {
detail => 'Test report details.',
photo => '',
name => 'Joe Bloggs',
+ email => $test_email,
may_show_name => '1',
phone => '07903 123 456',
category => 'Trees',
diff --git a/templates/email/default/problem-confirm-not-sending.txt b/templates/email/default/problem-confirm-not-sending.txt
new file mode 100644
index 000000000..2443805bb
--- /dev/null
+++ b/templates/email/default/problem-confirm-not-sending.txt
@@ -0,0 +1,32 @@
+Subject: Confirm your report on [% INCLUDE 'site-name.txt' | trim %]
+
+Hello [% report.name %],
+
+Please click on the link below to confirm that you want your report to appear
+on [% INCLUDE 'site-name.txt' | trim %], despite not being sent to the
+council:
+
+[% token_url %]
+
+If your email program does not let you click on this link, copy and paste it
+into your web browser and press return.
+
+Your problem had the title:
+
+[% report.title %]
+
+And details:
+
+[% report.detail %]
+
+If you no longer wish your report to be displayed on the site, please take no
+further action.
+
+Thank you for supporting [% INCLUDE 'site-name.txt' | trim %].
+
+
+
+[% INCLUDE 'signature.txt' %]
+
+This email was sent automatically, from an unmonitored email account - so
+please do not reply to it.