aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2013-02-21 12:31:17 +0000
committerMatthew Somerville <matthew@mysociety.org>2013-02-21 12:31:17 +0000
commite2bf144a6aaa19779fc55a04081a3c269b9d0f81 (patch)
tree00318d801d35948938743608252fccd2d1b4e585 /t/cobrand
parenteb0c0d42f3596c5dc21e9bcdcc02a4008a541c34 (diff)
parentf8a8948ddb790e7e7593d538c55a3a278fbf3973 (diff)
Merge remote branch 'origin/zurich'
(locale ignored, will rerun .po extraction after to get all changes.) Conflicts: locale/FixMyStreet.po locale/cy_GB.UTF-8/LC_MESSAGES/EmptyHomes.po locale/de_CH.UTF-8/LC_MESSAGES/FixMyStreet.po locale/nb_NO.UTF-8/LC_MESSAGES/FixMyStreet.po locale/nn_NO.UTF-8/LC_MESSAGES/FixMyStreet.po templates/web/fixmystreet/report/banner.html templates/web/zurich/faq/faq-de-ch.html
Diffstat (limited to 't/cobrand')
-rw-r--r--t/cobrand/zurich.t56
1 files changed, 52 insertions, 4 deletions
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index f354f0da4..71c904ed9 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',
@@ -49,7 +52,7 @@ my $user = $mech->log_in_ok( 'dm1@example.org') ;
$user->from_body( undef );
$user->update;
$mech->get_ok( '/admin' );
-is $mech->uri->path, '/auth', "got sent to the sign in page";
+is $mech->uri->path, '/my', "got sent to /my";
$user->from_body( 2 );
$user->update;
@@ -61,6 +64,7 @@ $mech->content_contains( DateTime->now->strftime("%d.%m.%Y") );
$mech->content_contains( 'Erfasst' );
$mech->get_ok( '/admin/report_edit/' . $report->id );
+$mech->content_contains( 'Unbest&auml;tigt' ); # Unconfirmed email
$mech->submit_form_ok( { with_fields => { state => 'confirmed' } } );
$mech->get_ok( '/report/' . $report->id );
$mech->content_contains('Aufgenommen');
@@ -82,7 +86,7 @@ $mech->content_contains( 'Some internal notes' );
# Original description
$mech->submit_form_ok( { with_fields => { detail => 'Edited details text.' } } );
$mech->content_contains( 'Edited details text.' );
-$mech->content_contains( 'originally entered: &ldquo;Test Test 1 for 2 Detail&rdquo;' );
+$mech->content_contains( 'Originaltext: &ldquo;Test Test 1 for 2 Detail&rdquo;' );
$mech->get_ok( '/admin/report_edit/' . $report->id );
$mech->submit_form_ok( { with_fields => { body_subdivision => 3 } } );
@@ -101,7 +105,7 @@ $mech->log_out_ok;
$user = $mech->log_in_ok( 'sdm1@example.org') ;
$mech->get_ok( '/admin' );
-is $mech->uri->path, '/auth', "got sent to the sign in page";
+is $mech->uri->path, '/my', "got sent to /my";
$user->from_body( 3 );
$user->update;
@@ -149,6 +153,7 @@ $report->extra ( { %$extra } );
$report->update;
$mech->get_ok( '/admin/report_edit/' . $report->id );
+$mech->content_lacks( 'Unbest&auml;tigt' ); # Confirmed email
$mech->submit_form_ok( { with_fields => { status_update => 'FINAL UPDATE' } } );
$mech->form_with_fields( 'status_update' );
$mech->submit_form_ok( { button => 'publish_response' } );
@@ -160,9 +165,52 @@ $mech->content_contains('FINAL UPDATE');
$email = $mech->get_email;
like $email->header('To'), qr/test\@example.com/, 'to line looks correct';
+like $email->header('From'), qr/division\@example.org/, 'from 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' );