diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/report_updates.t | 45 | ||||
-rw-r--r-- | t/open311.t | 34 |
2 files changed, 75 insertions, 4 deletions
diff --git a/t/app/controller/report_updates.t b/t/app/controller/report_updates.t index cf6af16cb..82670d6cc 100644 --- a/t/app/controller/report_updates.t +++ b/t/app/controller/report_updates.t @@ -577,7 +577,12 @@ for my $test ( is $update->problem_state, $test->{state}, 'problem state set'; my $update_meta = $mech->extract_update_metas; - like $update_meta->[0], qr/marked as $test->{fields}->{state}$/, 'update meta includes state change'; + # setting it to confirmed shouldn't say anything + if ( $test->{fields}->{state} ne 'confirmed' ) { + like $update_meta->[0], qr/marked as $test->{fields}->{state}$/, 'update meta includes state change'; + } else { + like $update_meta->[0], qr/reopened$/, 'update meta includes state change'; + } like $update_meta->[0], qr{Test User \(Westminster City Council\)}, 'update meta includes council name'; $mech->content_contains( 'Test User (<strong>Westminster City Council</strong>)', 'council name in bold'); @@ -586,6 +591,44 @@ for my $test ( }; } +subtest 'check meta correct for comments marked confirmed but not marked open' => sub { + $report->comments->delete; + my $comment = FixMyStreet::App->model('DB::Comment')->create( + { + user => $user, + problem_id => $report->id, + text => 'update text', + confirmed => DateTime->now, + problem_state => 'confirmed', + anonymous => 0, + mark_open => 0, + mark_fixed => 0, + state => 'confirmed', + } + ); + + $mech->get_ok( "/report/" . $report->id ); + my $update_meta = $mech->extract_update_metas; + like $update_meta->[0], qr/reopened$/, + 'update meta does not say reopened'; + + $comment->update( { mark_open => 1, problem_state => undef } ); + $mech->get_ok( "/report/" . $report->id ); + $update_meta = $mech->extract_update_metas; + + unlike $update_meta->[0], qr/marked as open$/, + 'update meta does not says marked as open'; + like $update_meta->[0], qr/reopened$/, 'update meta does say reopened'; + + $comment->update( { mark_open => 0, problem_state => undef } ); + $mech->get_ok( "/report/" . $report->id ); + $update_meta = $mech->extract_update_metas; + + unlike $update_meta->[0], qr/marked as open$/, + 'update meta does not says marked as open'; + unlike $update_meta->[0], qr/reopened$/, 'update meta does not say reopened'; + }; + $user->from_council(0); $user->update; diff --git a/t/open311.t b/t/open311.t index f082179ea..835d8d8cb 100644 --- a/t/open311.t +++ b/t/open311.t @@ -410,20 +410,48 @@ for my $test ( }; } +subtest 'No request id in reponse' => sub { + my $results; + warning_like { + $results = make_service_req( + $problem, + { url => 'http://example.com/report/1' }, + $problem->category, + '<?xml version="1.0" encoding="utf-8"?><service_requests><request><service_request_id></service_request_id></request></service_requests>' + ); + } qr/Failed to submit problem \d+ over Open311/, 'correct error message for missing request_id'; + + is $results->{ res }, 0, 'No request_id is a failure'; +}; + +subtest 'Bad data in request_id element in reponse' => sub { + my $results; + warning_like { + $results = make_service_req( + $problem, + { url => 'http://example.com/report/1' }, + $problem->category, + '<?xml version="1.0" encoding="utf-8"?><service_requests><request><service_request_id><bad_data>BAD</bad_data></service_request_id></request></service_requests>' + ); + } qr/Failed to submit problem \d+ over Open311/, 'correct error message for bad data in request_id'; + + is $results->{ res }, 0, 'No request_id is a failure'; +}; + subtest 'No update id in reponse' => sub { my $results; warning_like { $results = make_update_req( $comment, '<?xml version="1.0" encoding="utf-8"?><service_request_updates><request_update><update_id></update_id></request_update></service_request_updates>' ) - } qr/Failed to submit comment \d+ over Open311/, 'correct error message'; + } qr/Failed to submit comment \d+ over Open311/, 'correct error message for missing update_id'; is $results->{ res }, 0, 'No update_id is a failure'; }; -subtest 'error reponse' => sub { +subtest 'error response' => sub { my $results; warning_like { $results = make_update_req( $comment, '<?xml version="1.0" encoding="utf-8"?><errors><error><code>400</code><description>There was an error</description</error></errors>' ) - } qr/Failed to submit comment \d+ over Open311.*There was an error/, 'correct error messages'; + } qr/Failed to submit comment \d+ over Open311.*There was an error/, 'correct error messages for general error'; is $results->{ res }, 0, 'error in response is a failure'; }; |