From 36e192cd4df03a20f81fc3f366f9e354369f661d Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Fri, 20 Sep 2024 11:08:13 +0100 Subject: [PATCH] =?UTF-8?q?[Surrey]=20Don=E2=80=99t=20pass=20blank=20updat?= =?UTF-8?q?es=20to=20Boomi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- perllib/Open311/Endpoint/Integration/Boomi.pm | 6 ++++- t/open311/endpoint/surrey_boomi.t | 26 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/perllib/Open311/Endpoint/Integration/Boomi.pm b/perllib/Open311/Endpoint/Integration/Boomi.pm index 40da49f9e..6dc270d60 100644 --- a/perllib/Open311/Endpoint/Integration/Boomi.pm +++ b/perllib/Open311/Endpoint/Integration/Boomi.pm @@ -294,7 +294,11 @@ sub post_service_request_update { my $hash = substr(md5_hex(join('', @parts)), 0, 8); my $update_id = $args->{service_request_id} . "_" . $hash; - my $service_request_id = $self->boomi->upsertHighwaysTicket($ticket); + if ($args->{description}) { + # State changes on FMS may create updates with empty descriptions, which + # we don't want to send to Boomi as it will return an error. + my $service_request_id = $self->boomi->upsertHighwaysTicket($ticket); + } return Open311::Endpoint::Service::Request::Update::mySociety->new( service_request_id => $args->{service_request_id}, diff --git a/t/open311/endpoint/surrey_boomi.t b/t/open311/endpoint/surrey_boomi.t index 8e1937fcb..d505e178a 100644 --- a/t/open311/endpoint/surrey_boomi.t +++ b/t/open311/endpoint/surrey_boomi.t @@ -38,6 +38,8 @@ $lwp->mock(request => sub { ] }; return HTTP::Response->new(200, 'OK', [], encode_json({"ticket" => { system => "Zendesk", id => 123457 }})); + } elsif ($content && !$content->{comments}->[0]->{body}) { + return HTTP::Response->new(400, 'Bad request', [], "Bad request"); } else { is_deeply $content, { "comments" => [ @@ -454,6 +456,30 @@ subtest "POST Service Request Update with photo" => sub { restore_time(); }; +subtest "POST Service Request Update with blank description" => sub { + set_fixed_time('2023-05-01T12:00:00Z'); + + my $res = $surrey_endpoint->run_test_request( + POST => '/servicerequestupdates.json', + jurisdiction_id => 'surrey_boomi', + api_key => 'api-key', + updated_datetime => '2023-05-02T12:43:00Z', + service_request_id => 'Zendesk_123458', + status => 'FIXED', + description => '', + last_name => "Smith", + first_name => "John", + update_id => '10000002', + ); + is $res->code, 200; + is_deeply decode_json($res->content), + [ { + 'update_id' => "Zendesk_123458_830d4308", + } ], 'correct json returned'; + + restore_time(); +}; + subtest "GET Service Requests" => sub { my $res = $surrey_endpoint->run_test_request( GET => '/requests.json?jurisdiction_id=surrey_boomi&api_key=api-key&start_date=2024-05-01T09:00:00Z&end_date=2024-05-01T10:00:00Z',