aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--locale/de_CH.UTF-8/LC_MESSAGES/FixMyStreet.po2
-rw-r--r--perllib/FixMyStreet/SendReport/Zurich.pm10
-rw-r--r--t/cobrand/zurich.t47
-rw-r--r--templates/email/zurich/submit-external-personal.txt2
4 files changed, 54 insertions, 7 deletions
diff --git a/locale/de_CH.UTF-8/LC_MESSAGES/FixMyStreet.po b/locale/de_CH.UTF-8/LC_MESSAGES/FixMyStreet.po
index b19301413..7db8e8a19 100644
--- a/locale/de_CH.UTF-8/LC_MESSAGES/FixMyStreet.po
+++ b/locale/de_CH.UTF-8/LC_MESSAGES/FixMyStreet.po
@@ -474,7 +474,7 @@ msgstr "An Fachbereich zuweisen:"
#: templates/web/zurich/report/updates.html:11
msgid "Assigned to %s"
-msgstr "An Fachbereich zuweisen:"
+msgstr "An Fachbereich zuweisen: %s"
#: templates/web/default/open311/index.html:17
msgid ""
diff --git a/perllib/FixMyStreet/SendReport/Zurich.pm b/perllib/FixMyStreet/SendReport/Zurich.pm
index e0c95283e..4930ff61e 100644
--- a/perllib/FixMyStreet/SendReport/Zurich.pm
+++ b/perllib/FixMyStreet/SendReport/Zurich.pm
@@ -9,12 +9,14 @@ sub build_recipient_list {
# Only one body ever, most of the time with an email endpoint
my $body = @{ $self->bodies }[0];
- $body = FixMyStreet::App->model("DB::Body")->find( { id => $row->external_body } )
- if $row->external_body;
+ if ( $row->external_body ) {
+ $body = FixMyStreet::App->model("DB::Body")->find( { id => $row->external_body } );
+ $h->{bodies_name} = $body->name;
+ }
my $body_email = $body->endpoint;
- my @bodies = $body->bodies;
- if ($body->parent && @bodies) {
+ my $parent = $body->parent;
+ if ($parent && !$parent->parent) {
# Division, might have an individual contact email address
my $contact = FixMyStreet::App->model("DB::Contact")->find( {
body_id => $body->id,
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 4c7bdb25d..de243eac0 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -1,5 +1,4 @@
# TODO
-# Report to third party (with third_personal)
# Overdue alerts
use strict;
@@ -30,6 +29,10 @@ $subdivision->parent( $division->id );
$subdivision->send_method( 'Zurich' );
$subdivision->endpoint( 'subdivision@example.org' );
$subdivision->update;
+my $external_body = $mech->create_body_ok( 4, 'External Body' );
+$external_body->send_method( 'Zurich' );
+$external_body->endpoint( 'external_body@example.org' );
+$external_body->update;
my @reports = $mech->create_problems_for_body( 1, 2, 'Test', {
state => 'unconfirmed',
@@ -165,6 +168,48 @@ like $email->header('To'), qr/test\@example.com/, 'to line looks correct';
like $email->body, qr/FINAL UPDATE/, 'body looks correct';
$mech->clear_emails_ok;
+# Report assigned to third party
+
+@reports = $mech->create_problems_for_body( 1, 2, 'Third', {
+ state => 'unconfirmed',
+ confirmed => undef,
+ cobrand => 'zurich',
+});
+$report = $reports[0];
+
+$mech->get_ok( '/admin/report_edit/' . $report->id );
+$mech->submit_form_ok( { with_fields => { body_external => 4 } } );
+$mech->get_ok( '/report/' . $report->id );
+$mech->content_contains('Erledigt');
+$mech->content_contains('Third Test');
+$mech->content_contains('An Fachbereich zuweisen: External Body');
+FixMyStreet::App->model('DB::Problem')->send_reports('zurich');
+$email = $mech->get_email;
+like $email->header('Subject'), qr/Neue Meldung/, 'subject looks okay';
+like $email->header('To'), qr/external_body\@example.org/, 'to line looks correct';
+like $email->body, qr/External Body/, 'body has right name';
+unlike $email->body, qr/test\@example.com/, 'body does not contain email address';
+$mech->clear_emails_ok;
+
+# Test calling back, and third_personal boolean setting
+$mech->get_ok( '/admin' );
+is $mech->uri->path, '/admin', "am logged in";
+$mech->content_contains( 'report_edit/' . $report->id );
+$mech->get_ok( '/admin/report_edit/' . $report->id );
+$mech->submit_form_ok( { with_fields => { state => 'unconfirmed' } } );
+$mech->submit_form_ok( { with_fields => { body_external => 4, third_personal => 1 } } );
+$mech->get_ok( '/report/' . $report->id );
+$mech->content_contains('Erledigt');
+$mech->content_contains('Third Test');
+$mech->content_contains('An Fachbereich zuweisen: External Body');
+FixMyStreet::App->model('DB::Problem')->send_reports('zurich');
+$email = $mech->get_email;
+like $email->header('Subject'), qr/Neue Meldung/, 'subject looks okay';
+like $email->header('To'), qr/external_body\@example.org/, 'to line looks correct';
+like $email->body, qr/External Body/, 'body has right name';
+like $email->body, qr/test\@example.com/, 'body does contain email address';
+$mech->clear_emails_ok;
+
$mech->delete_problems_for_body( 2 );
$mech->delete_user( 'dm1@example.org' );
$mech->delete_user( 'sdm1@example.org' );
diff --git a/templates/email/zurich/submit-external-personal.txt b/templates/email/zurich/submit-external-personal.txt
index 56968c036..027afd4bf 100644
--- a/templates/email/zurich/submit-external-personal.txt
+++ b/templates/email/zurich/submit-external-personal.txt
@@ -10,4 +10,4 @@ Reporter name: <?=$values['name']?>
Reporter email: <?=$values['email']?>
-Reporter phone: <?=$values['phone']?>
+<?=$values['phone_line']?>