diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/report_inspect.t | 4 | ||||
-rw-r--r-- | t/open311.t | 61 | ||||
-rw-r--r-- | t/open311/getservicerequestupdates.t | 14 |
3 files changed, 70 insertions, 9 deletions
diff --git a/t/app/controller/report_inspect.t b/t/app/controller/report_inspect.t index f2b300e11..6a001225d 100644 --- a/t/app/controller/report_inspect.t +++ b/t/app/controller/report_inspect.t @@ -36,8 +36,8 @@ my $report_id = $report->id; my $report2_id = $report2->id; my $report3_id = $report3->id; - -my $user = $mech->log_in_ok('test@example.com'); +$mech->create_user_ok('body@example.com', name => 'Body User'); +my $user = $mech->log_in_ok('body@example.com'); $user->set_extra_metadata('categories', [ $contact->id ]); $user->update( { from_body => $oxon } ); diff --git a/t/open311.t b/t/open311.t index 35d9b0ecb..4dc1b2959 100644 --- a/t/open311.t +++ b/t/open311.t @@ -133,8 +133,38 @@ for my $test ( } ], params => [ - [ 'attribute[title]', 'A title', 'extra paramater used correctly' ] - ] + [ 'attribute[title]', 'A title', 'extra parameter used correctly' ] + ], + debug_contains => 'attribute\[title\]: A title', + }, + { + desc => 'undef extra values handled', + extra => [ + { + name => 'title', + value => undef, + } + ], + params => [ + [ 'attribute[title]', '', 'undef extra parameter used correctly' ] + ], + # multi line warnings are not handled well so just match the + # first line + warning => qr/POST requests.xml/, + debug_contains => 'attribute\[title\]: $', + }, + { + desc => '0 extra values handled', + extra => [ + { + name => 'title', + value => 0, + } + ], + params => [ + [ 'attribute[title]', '0', '0 extra parameter used correctly' ] + ], + debug_contains => 'attribute\[title\]: 0', }, { desc => 'first and last names in extra used correctly', @@ -178,11 +208,24 @@ for my $test ( my $extra = { url => 'http://example.com/report/1', }; - my $results = make_service_req( $problem, $extra, $problem->category, -'<?xml version="1.0" encoding="utf-8"?><service_requests><request><service_request_id>248</service_request_id></request></service_requests>' - ); + my $results; + if ( $test->{warning} ) { + warnings_exist { + $results = make_service_req( $problem, $extra, $problem->category, + '<?xml version="1.0" encoding="utf-8"?><service_requests><request><service_request_id>248</service_request_id></request></service_requests>' + ); + } [ $test->{warning} ], 'warning generated by service request call'; + } else { + $results = make_service_req( $problem, $extra, $problem->category, + '<?xml version="1.0" encoding="utf-8"?><service_requests><request><service_request_id>248</service_request_id></request></service_requests>' + ); + } my $c = CGI::Simple->new( $results->{req}->content ); + if ( $test->{debug_contains} ) { + like $results->{o}->debug_details, qr/$test->{debug_contains}/m, 'extra handled correctly in debug'; + } + for my $param ( @{ $test->{params} } ) { is $c->param( $param->[0] ), $param->[1], $param->[2]; } @@ -196,6 +239,12 @@ for my $test ( first_name => 'Nom', last_name => 'de Report', }, + { + desc => 'Check single word name handled correctly', + name => 'Nom', + first_name => 'Nom', + last_name => '', + } ) { subtest $test->{desc} => sub { $problem->extra( undef ); @@ -756,5 +805,5 @@ sub _make_req { my $req = $o->test_req_used; - return { res => $res, req => $req }; + return { res => $res, req => $req, o => $o }; } diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t index cc319cbdc..dad3bb0d1 100644 --- a/t/open311/getservicerequestupdates.t +++ b/t/open311/getservicerequestupdates.t @@ -358,6 +358,18 @@ for my $test ( end_state => 'investigating', }, { + desc => 'unchanging state does not trigger auto-response template', + description => '', + xml_description => '', + external_id => 638344, + start_state => 'investigating', + comment_status => 'INVESTIGATING', + mark_fixed => 0, + mark_open => 0, + problem_state => 'investigating', + end_state => 'investigating', + }, + { desc => 'open status does not re-open hidden report', description => 'This is a note', external_id => 638344, @@ -689,7 +701,7 @@ subtest 'check that external_status_code is stored correctly' => sub { $problem->discard_changes; is $problem->comments->count, 2, 'two comments after fetching updates'; - my @comments = $problem->comments->all; + my @comments = $problem->comments->search(undef, { order_by => [ 'created' ] } )->all; is $comments[0]->get_extra_metadata('external_status_code'), "060", "correct external status code on first comment"; is $comments[1]->get_extra_metadata('external_status_code'), "101", "correct external status code on second comment"; |