diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/around.t | 2 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 2 | ||||
-rw-r--r-- | t/app/model/comment.t | 4 | ||||
-rw-r--r-- | t/app/model/problem.t | 8 | ||||
-rw-r--r-- | t/cobrand/zurich.t | 56 |
5 files changed, 60 insertions, 12 deletions
diff --git a/t/app/controller/around.t b/t/app/controller/around.t index 0f01a9ea9..fa2d94aed 100644 --- a/t/app/controller/around.t +++ b/t/app/controller/around.t @@ -7,7 +7,7 @@ my $mech = FixMyStreet::TestMech->new; subtest "check that if no query we get sent back to the homepage" => sub { $mech->get_ok('/around'); - is $mech->uri->path, '/around', "still at '/around'"; + is $mech->uri->path, '/', "redirected to '/'"; }; # x,y requests were generated by the old map code. We keep the behavior for diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 868977953..722c3c39c 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -17,7 +17,7 @@ ok -e $sample_file, "sample file $sample_file exists"; subtest "test that bare requests to /report/new get redirected" => sub { $mech->get_ok('/report/new'); - is $mech->uri->path, '/around', "went to /around"; + is $mech->uri->path, '/', "went to /"; is_deeply { $mech->uri->query_form }, {}, "query empty"; $mech->get_ok('/report/new?pc=SW1A%201AA'); diff --git a/t/app/model/comment.t b/t/app/model/comment.t index 93104c2e5..3141af828 100644 --- a/t/app/model/comment.t +++ b/t/app/model/comment.t @@ -23,5 +23,5 @@ my $comment = $comment_rs->new( } ); -is $comment->confirmed_local, undef, 'inflating null confirmed ok'; -is $comment->created_local, undef, 'inflating null confirmed ok'; +is $comment->confirmed, undef, 'inflating null confirmed ok'; +is $comment->created, undef, 'inflating null confirmed ok'; diff --git a/t/app/model/problem.t b/t/app/model/problem.t index a92e3b079..6ba2bbde4 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -32,10 +32,10 @@ my $problem = $problem_rs->new( } ); -is $problem->confirmed_local, undef, 'inflating null confirmed ok'; -is $problem->whensent_local, undef, 'inflating null confirmed ok'; -is $problem->lastupdate_local, undef, 'inflating null confirmed ok'; -is $problem->created_local, undef, 'inflating null confirmed ok'; +is $problem->confirmed, undef, 'inflating null confirmed ok'; +is $problem->whensent, undef, 'inflating null confirmed ok'; +is $problem->lastupdate, undef, 'inflating null confirmed ok'; +is $problem->created, undef, 'inflating null confirmed ok'; for my $test ( { 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ä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: “Test Test 1 for 2 Detail”' ); +$mech->content_contains( 'Originaltext: “Test Test 1 for 2 Detail”' ); $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ä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' ); |