aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2015-07-22 12:17:08 +0100
committerDave Arter <davea@mysociety.org>2015-10-06 09:09:27 +0100
commit01dc45846079044669d12c6a1d2c67212f1a8ae6 (patch)
treef2900ffed95785dbcb2a0a54085517316cd3185e /t/cobrand
parenta3b1269d17bcaeeabba5d81f92f8b7b2521a0fcb (diff)
[Zurich] Set report's public response before sending email to user
The 'public response' to a problem was being omitted from the email sent to the user when the problem is closed, because the email was sent before the report's 'extra' field was updated with the response body text. This commit sets the public response on the problem before sending the email.
Diffstat (limited to 't/cobrand')
-rw-r--r--t/cobrand/zurich.t38
1 files changed, 36 insertions, 2 deletions
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 4429a94ca..721ee547c 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -632,6 +632,40 @@ subtest "external report triggers email" => sub {
like $email->body, qr/test\@example.com/, 'body contains email address';
$mech->clear_emails_ok;
};
+
+ subtest "Closure email includes public response" => sub {
+ my $PUBLIC_RESPONSE = "This is the public response to your report. Freundliche Gruesse.";
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ MAP_TYPE => 'Zurich,OSM',
+ }, sub {
+ # set as extern
+ reset_report_state($report);
+ $report->state('planned');
+ $report->set_extra_metadata('closure_status' => 'closed');
+ $report->set_extra_metadata('email_confirmed' => 1);
+ $report->unset_extra_metadata('public_response');
+ $report->update;
+ is ($report->state, 'planned', 'Sanity check') or die;
+
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+
+ $mech->form_with_fields( 'publish_response' );
+ $mech->submit_form_ok( {
+ button => 'publish_response',
+ with_fields => {
+ body_external => $external_body->id,
+ external_message => $EXTERNAL_MESSAGE,
+ status_update => $PUBLIC_RESPONSE,
+ } });
+ };
+ $email = $mech->get_email;
+ my $report_id = $report->id;
+ like $email->header('Subject'), qr/Meldung #$report_id/, 'subject looks okay';
+ like $email->header('To'), qr/test\@example.com/, 'to line looks correct';
+ like $email->body, qr/$PUBLIC_RESPONSE/, 'public_response was passed on' or die $email->body;
+ $mech->clear_emails_ok;
+ };
$report->comments->delete; # delete the comments, as they confuse later tests
};
@@ -821,8 +855,8 @@ subtest "test admin_log" => sub {
# XXX: following is dependent on all of test up till now, rewrite to explicitly
# test which things need to be logged!
- is scalar @entries, 3, 'State changes logged';
- is $entries[-1]->action, 'state change to investigating', 'State change logged as expected';
+ is scalar @entries, 4, 'State changes logged';
+ is $entries[-1]->action, 'state change to closed', 'State change logged as expected';
};
subtest 'email images to external partners' => sub {