@@ -, +, @@ priority is not provided --- Koha/REST/V1/Holds.pm | 6 +++--- t/db_dependent/api/v1/holds.t | 23 ++++++++++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) --- a/Koha/REST/V1/Holds.pm +++ a/Koha/REST/V1/Holds.pm @@ -243,9 +243,9 @@ sub edit { my $body = $c->req->json; - my $pickup_library_id = $body->{pickup_library_id}; - my $priority = $body->{priority}; - my $suspended_until = $body->{suspended_until}; + my $pickup_library_id = $body->{pickup_library_id} // $hold->branchcode; + my $priority = $body->{priority} // $hold->priority; + my $suspended_until = $body->{suspended_until} // $hold->suspend_until; if ($suspended_until) { $suspended_until = output_pref(dt_from_string($suspended_until, 'rfc3339')); --- a/t/db_dependent/api/v1/holds.t +++ a/t/db_dependent/api/v1/holds.t @@ -47,6 +47,7 @@ my $t = Test::Mojo->new('Koha::REST::V1'); my $categorycode = $builder->build({ source => 'Category' })->{categorycode}; my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; +my $branchcode2 = $builder->build({ source => 'Branch' })->{branchcode}; my $itemtype = $builder->build({ source => 'Itemtype' })->{itemtype}; # Generic password for everyone @@ -163,6 +164,9 @@ my $put_data = { priority => 2, suspended_until => output_pref({ dt => $suspended_until, dateformat => 'rfc3339' }), }; +my $put_data2 = { + pickup_library_id => $branchcode2 +}; subtest "Test endpoints without authentication" => sub { plan tests => 8; @@ -198,7 +202,7 @@ subtest "Test endpoints without permission" => sub { subtest "Test endpoints with permission" => sub { - plan tests => 44; + plan tests => 51; $t->get_ok( "//$userid_1:$password@/api/v1/holds" ) ->status_is(200) @@ -211,11 +215,24 @@ subtest "Test endpoints with permission" => sub { ->json_is('/0/patron_id', $patron_2->borrowernumber) ->json_hasnt('/1'); + # While suspended_until is date-time, it's always set to midnight. + my $expected_suspended_until = $suspended_until->strftime('%FT00:00:00%z'); + substr($expected_suspended_until, -2, 0, ':'); + $t->put_ok( "//$userid_1:$password@/api/v1/holds/$reserve_id" => json => $put_data ) ->status_is(200) ->json_is( '/hold_id', $reserve_id ) - ->json_is( '/suspended_until', output_pref({ dt => $suspended_until, dateformat => 'rfc3339' }) ) - ->json_is( '/priority', 2 ); + ->json_is( '/suspended_until', $expected_suspended_until ) + ->json_is( '/priority', 2 ) + ->json_is( '/pickup_library_id', $branchcode ); + + # Change only pickup library, everything else should remain + $t->put_ok( "//$userid_1:$password@/api/v1/holds/$reserve_id" => json => $put_data2 ) + ->status_is(200) + ->json_is( '/hold_id', $reserve_id ) + ->json_is( '/suspended_until', $expected_suspended_until ) + ->json_is( '/priority', 2 ) + ->json_is( '/pickup_library_id', $branchcode2 ); $t->delete_ok( "//$userid_3:$password@/api/v1/holds/$reserve_id" ) ->status_is(200); --