Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Surrey] Don’t pass blank updates to Boomi #364

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion perllib/Open311/Endpoint/Integration/Boomi.pm
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,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.
$self->boomi->upsertHighwaysTicket($ticket);
}

return Open311::Endpoint::Service::Request::Update::mySociety->new(
service_request_id => $args->{service_request_id},
Expand Down
26 changes: 26 additions & 0 deletions t/open311/endpoint/surrey_boomi.t
Original file line number Diff line number Diff line change
Expand Up @@ -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" => [
Expand Down Expand Up @@ -504,6 +506,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',
Expand Down
Loading