Bugzilla – Attachment 99241 Details for
Bug 24680
Hold modification endpoints don't always work properly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24680: Fix PUT api/v1/holds/{hold_id} to work also when priority is not provided
Bug-24680-Fix-PUT-apiv1holdsholdid-to-work-also-wh.patch (text/plain), 3.15 KB, created by
Ere Maijala
on 2020-02-19 09:47:48 UTC
(
hide
)
Description:
Bug 24680: Fix PUT api/v1/holds/{hold_id} to work also when priority is not provided
Filename:
MIME Type:
Creator:
Ere Maijala
Created:
2020-02-19 09:47:48 UTC
Size:
3.15 KB
patch
obsolete
>From 0956fbfc05145d5449b302eae68a095fa0b1148b Mon Sep 17 00:00:00 2001 >From: Ere Maijala <ere.maijala@helsinki.fi> >Date: Wed, 19 Feb 2020 11:43:08 +0200 >Subject: [PATCH] Bug 24680: Fix PUT api/v1/holds/{hold_id} to work also when > priority is not provided > >Before this fix the endpoint would accept the request but fail to actually update the hold if the request does not contain a priority parameter. >--- > Koha/REST/V1/Holds.pm | 6 +++--- > t/db_dependent/api/v1/holds.t | 17 +++++++++++++++-- > 2 files changed, 18 insertions(+), 5 deletions(-) > >diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm >index 0fd1b3f4df..629a037d99 100644 >--- a/Koha/REST/V1/Holds.pm >+++ b/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')); >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index 6e41591ad0..01b9733e42 100644 >--- a/t/db_dependent/api/v1/holds.t >+++ b/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) >@@ -219,7 +223,16 @@ subtest "Test endpoints with permission" => sub { > ->status_is(200) > ->json_is( '/hold_id', $reserve_id ) > ->json_is( '/suspended_until', $expected_suspended_until ) >- ->json_is( '/priority', 2 ); >+ ->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); >-- >2.17.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24680
:
99241
|
99242
|
99476
|
99477
|
99481
|
99482
|
99531
|
99532
|
99534
|
99535
|
99644
|
99645