Bugzilla – Attachment 99532 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 end_date returned from api/v1/holds/{hold_id}/suspension endpoint
Bug-24680-Fix-enddate-returned-from-apiv1holdshold.patch (text/plain), 3.08 KB, created by
Ere Maijala
on 2020-02-24 14:50:35 UTC
(
hide
)
Description:
Bug 24680: Fix end_date returned from api/v1/holds/{hold_id}/suspension endpoint
Filename:
MIME Type:
Creator:
Ere Maijala
Created:
2020-02-24 14:50:35 UTC
Size:
3.08 KB
patch
obsolete
>From 3d903ef5ce953c03e3f15ac57712d6ab78b8babf Mon Sep 17 00:00:00 2001 >From: Ere Maijala <ere.maijala@helsinki.fi> >Date: Wed, 19 Feb 2020 11:45:04 +0200 >Subject: [PATCH] Bug 24680: Fix end_date returned from > api/v1/holds/{hold_id}/suspension endpoint > >Before this patch the response would return current date as the suspension end date for a hold that is suspended with no end date. >--- > Koha/REST/V1/Holds.pm | 16 ++++++++++------ > t/db_dependent/api/v1/holds.t | 29 +++++++++++++++++++++-------- > 2 files changed, 31 insertions(+), 14 deletions(-) > >diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm >index dcc46798ff..a806d6757a 100644 >--- a/Koha/REST/V1/Holds.pm >+++ b/Koha/REST/V1/Holds.pm >@@ -309,15 +309,19 @@ sub suspend { > $hold->suspend_hold($date); > $hold->discard_changes; > $c->res->headers->location( $c->req->url->to_string ); >+ my $suspend_end_date; >+ if ($hold->suspend_until) { >+ $suspend_end_date = output_pref({ >+ dt => dt_from_string( $hold->suspend_until ), >+ dateformat => 'rfc3339', >+ dateonly => 1 >+ } >+ ); >+ } > return $c->render( > status => 201, > openapi => { >- end_date => output_pref( >- { dt => dt_from_string( $hold->suspend_until ), >- dateformat => 'rfc3339', >- dateonly => 1 >- } >- ) >+ end_date => $suspend_end_date > } > ); > } >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index bb9870079e..df10cbca61 100644 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -375,7 +375,7 @@ $schema->storage->txn_rollback; > > subtest 'suspend and resume tests' => sub { > >- plan tests => 21; >+ plan tests => 24; > > $schema->storage->txn_begin; > >@@ -402,15 +402,28 @@ subtest 'suspend and resume tests' => sub { > > $hold->discard_changes; # refresh object > >+ ok( $hold->is_suspended, 'Hold is suspended' ); >+ $t->json_is('/end_date', undef, 'Hold suspension has no end date'); >+ >+ my $end_date = output_pref({ >+ dt => dt_from_string( undef ), >+ dateformat => 'rfc3339', >+ dateonly => 1 >+ }); >+ >+ $t->post_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" => json => { end_date => $end_date } ); >+ >+ $hold->discard_changes; # refresh object >+ > ok( $hold->is_suspended, 'Hold is suspended' ); > $t->json_is( >- '/end_date', >- output_pref( >- { dt => dt_from_string( $hold->suspend_until ), >- dateformat => 'rfc3339', >- dateonly => 1 >- } >- ) >+ '/end_date', >+ output_pref({ >+ dt => dt_from_string( $hold->suspend_until ), >+ dateformat => 'rfc3339', >+ dateonly => 1 >+ }), >+ 'Hold suspension has correct end date' > ); > > $t->delete_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" ) >-- >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