diff options
author | Struan Donald <struan@exo.org.uk> | 2012-07-30 13:11:35 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2012-08-09 09:58:36 +0100 |
commit | f7c175d06dde929855ababb3e82d3f607b86133d (patch) | |
tree | 2b34b5ef5edc0ee313298128ffd2d26920fe5cd6 /t/open311.t | |
parent | ee5aa052f4b8b1baf36d4237ecccd2e774b37c10 (diff) |
Add option to allow service to be sent as deviceid over open311
turn this on for Bromley
Diffstat (limited to 't/open311.t')
-rw-r--r-- | t/open311.t | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/t/open311.t b/t/open311.t index 814b11f82..f082179ea 100644 --- a/t/open311.t +++ b/t/open311.t @@ -428,6 +428,49 @@ subtest 'error reponse' => sub { is $results->{ res }, 0, 'error in response is a failure'; }; +for my $test ( + { + desc => 'deviceid not sent by default', + use_service_as_id => 0, + service => 'iPhone', + }, + { + desc => 'if use_service_as_id set then deviceid sent with service as id', + use_service_as_id => 1, + service => 'iPhone', + }, + { + desc => 'no deviceid sent if service is blank', + use_service_as_id => 1, + service => '', + }, + ) +{ + subtest $test->{desc} => sub { + my $extra = { url => 'http://example.com/report/1', }; + $problem->service( $test->{service} ); + + 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>', + { use_service_as_deviceid => $test->{use_service_as_id} }, + ); + + is $results->{res}, 248, 'got request id'; + + my $c = CGI::Simple->new( $results->{req}->content ); + + if ( $test->{use_service_as_id} and $test->{service} ) { + is $c->param('deviceid'), $test->{service}, 'deviceid set to service'; + } + else { + is $c->param('deviceid'), undef, 'no deviceid is set'; + } + }; +} + done_testing(); sub make_update_req { |