Bugzilla – Attachment 65794 Details for
Bug 19072
REST API: Toggle suspend for /api/v1/holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19072: Toggle suspend for /api/v1/holds
Bug-19072-Toggle-suspend-for-apiv1holds.patch (text/plain), 3.58 KB, created by
Lari Taskula
on 2017-08-10 10:52:27 UTC
(
hide
)
Description:
Bug 19072: Toggle suspend for /api/v1/holds
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2017-08-10 10:52:27 UTC
Size:
3.58 KB
patch
obsolete
>From be180bc5196f6ebd431472f25c9630880f35a940 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Thu, 10 Aug 2017 12:31:43 +0300 >Subject: [PATCH] Bug 19072: Toggle suspend for /api/v1/holds > >This patch adds ability to toggle suspend for a hold. > >To test: >1. prove t/db_dependent/api/v1/holds.t >2. Send a PUT request to suspended hold with suspend_until parameter as null >3. Observe that hold is now resumed >--- > Koha/REST/V1/Hold.pm | 8 +++++++- > api/v1/swagger/paths/holds.json | 4 ++++ > t/db_dependent/api/v1/holds.t | 22 +++++++++++++++++++++- > 3 files changed, 32 insertions(+), 2 deletions(-) > >diff --git a/Koha/REST/V1/Hold.pm b/Koha/REST/V1/Hold.pm >index b282f07..f1fbde9 100644 >--- a/Koha/REST/V1/Hold.pm >+++ b/Koha/REST/V1/Hold.pm >@@ -153,10 +153,16 @@ sub edit { > reserve_id => $reserve_id, > branchcode => $branchcode, > rank => $priority, >- suspend_until => $suspend_until, > }; > > C4::Reserves::ModReserve($params); >+ >+ my $borrowernumber = $reserve->{borrowernumber}; >+ if (C4::Reserves::CanReserveBeCanceledFromOpac($reserve_id, $borrowernumber)){ >+ C4::Reserves::ToggleSuspend( $reserve_id, $suspend_until ) if >+ (defined $body->{suspend} || $suspend_until); >+ } >+ > $reserve = Koha::Holds->find($reserve_id); > > return $c->render( status => 200, openapi => $reserve ); >diff --git a/api/v1/swagger/paths/holds.json b/api/v1/swagger/paths/holds.json >index 55f1763..fc4555f 100644 >--- a/api/v1/swagger/paths/holds.json >+++ b/api/v1/swagger/paths/holds.json >@@ -273,6 +273,10 @@ > "description": "Pickup location", > "type": "string" > }, >+ "suspend": { >+ "description": "Suspend hold", >+ "type": "boolean" >+ }, > "suspend_until": { > "description": "Suspend until", > "type": "string", >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index 03ba478..022323d 100644 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -225,7 +225,7 @@ subtest "Test endpoints without permission" => sub { > ->status_is(403); > }; > subtest "Test endpoints without permission, but accessing own object" => sub { >- plan tests => 26; >+ plan tests => 36; > > my $reserve_id3 = C4::Reserves::AddReserve($branchcode, $nopermission->{'borrowernumber'}, > $biblionumber, undef, 2, undef, undef, undef, '', $itemnumber, 'W'); >@@ -319,6 +319,26 @@ subtest "Test endpoints without permission, but accessing own object" => sub { > ->status_is(200) > ->json_is('/reserve_id', $reserve_id3) > ->json_is('/branchcode', $branchcode2); >+ >+ $tx = $t->ua->build_tx(PUT => "/api/v1/holds/$reserve_id3" => json => { >+ suspend_until => $suspend_until >+ }); >+ $tx->req->cookies({name => 'CGISESSID', value => $session_nopermission->id}); >+ $t->request_ok($tx) # create hold to myself >+ ->status_is(200) >+ ->json_is('/reserve_id', $reserve_id3) >+ ->json_is('/suspend', Mojo::JSON->true) >+ ->json_like('/suspend_until', qr/^$suspend_until/); >+ >+ $tx = $t->ua->build_tx(PUT => "/api/v1/holds/$reserve_id3" => json => { >+ suspend => Mojo::JSON->false >+ }); >+ $tx->req->cookies({name => 'CGISESSID', value => $session_nopermission->id}); >+ $t->request_ok($tx) # create hold to myself >+ ->status_is(200) >+ ->json_is('/reserve_id', $reserve_id3) >+ ->json_is('/suspend', Mojo::JSON->false) >+ ->json_is('/suspend_until', undef); > }; > > subtest "Test endpoints with permission" => sub { >-- >2.7.4
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 19072
:
65792
|
65793
|
65794
|
65795
|
65796