diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/admin.t | 2 | ||||
-rw-r--r-- | t/app/controller/around.t | 2 | ||||
-rw-r--r-- | t/app/controller/auth.t | 2 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 2 | ||||
-rw-r--r-- | t/app/controller/report_updates.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 | 83 |
8 files changed, 90 insertions, 15 deletions
diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index 8963e417d..65e252954 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -1050,7 +1050,7 @@ subtest 'report search' => sub { $report->update; $mech->get_ok('/admin/reports?search=' . $report->user->email); - $mech->content_like( qr{<tr [^>]*hidden[^>]*> \s* <td> \s* $r_id \s* </td>}xs ); + $mech->content_like( qr{<tr [^>]*hidden[^>]*> \s* <td[^>]*> \s* $r_id \s* </td>}xs ); $report->state('fixed - user'); $report->update; 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/auth.t b/t/app/controller/auth.t index 67466e959..8d7bfbf4d 100644 --- a/t/app/controller/auth.t +++ b/t/app/controller/auth.t @@ -95,7 +95,7 @@ $mech->not_logged_in_ok; $mech->log_out_ok; $mech->get_ok($link); is $mech->uri, $link, "not logged in"; - $mech->content_contains( 'Link too old or already used', + $mech->content_contains( 'too old or already used', 'token now invalid' ); $mech->not_logged_in_ok; } 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/controller/report_updates.t b/t/app/controller/report_updates.t index cdebee35d..aa34b1a2c 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -807,7 +807,7 @@ subtest 'check meta correct for second comment marking as reopened' => sub { user => $user, problem_id => $report->id, text => 'update text', - confirmed => DateTime->now, + confirmed => DateTime->now + DateTime::Duration->new( minutes => 1 ), problem_state => 'confirmed', anonymous => 0, mark_open => 0, 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..ac0cc52b3 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; @@ -20,6 +19,8 @@ $mech->content_like( qr/zurich/i ); # Set up bodies my $zurich = $mech->create_body_ok( 1, 'Zurich' ); +$zurich->parent( undef ); +$zurich->update; my $division = $mech->create_body_ok( 2, 'Division 1' ); $division->parent( $zurich->id ); $division->send_method( 'Zurich' ); @@ -30,6 +31,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 +54,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 +66,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 +88,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 +107,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 +155,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 +167,77 @@ $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; +# Assign directly to planned, don't confirm email +@reports = $mech->create_problems_for_body( 1, 2, 'Second', { + state => 'unconfirmed', + confirmed => undef, + cobrand => 'zurich', +}); +$report = $reports[0]; + +$mech->get_ok( '/admin/report_edit/' . $report->id ); +$mech->submit_form_ok( { with_fields => { state => 'planned' } } ); +$mech->get_ok( '/report/' . $report->id ); +$mech->content_contains('In Bearbeitung'); +$mech->content_contains('Second Test'); + +$mech->get_ok( '/admin/report_edit/' . $report->id ); +$mech->content_contains( 'Unbestätigt' ); +$mech->submit_form_ok( { button => 'publish_response', with_fields => { status_update => 'FINAL UPDATE' } } ); + +$mech->get_ok( '/report/' . $report->id ); +$mech->content_contains('Erledigt'); +$mech->content_contains('Second Test'); +$mech->content_contains('FINAL UPDATE'); + +$mech->email_count_is(0); + +# 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' ); |