Bugzilla – Attachment 49951 Details for
Bug 16213
Allow to select hold's itemtype when using API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16213: Allow to select hold's itemtype when using API
Bug-16213-Allow-to-select-holds-itemtype-when-usin.patch (text/plain), 4.39 KB, created by
Julian Maurice
on 2016-04-06 11:31:54 UTC
(
hide
)
Description:
Bug 16213: Allow to select hold's itemtype when using API
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2016-04-06 11:31:54 UTC
Size:
4.39 KB
patch
obsolete
>From 4baf36ae08df5580908ecf18b14ee5d828d4916f Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Wed, 6 Apr 2016 13:12:51 +0200 >Subject: [PATCH] Bug 16213: Allow to select hold's itemtype when using API > >Depends on bug 15533 and bug 13903 > >Test plan: >1/ Use your usual "REST testing" tool to place a title-level hold with >an itemtype. The request should look like this: > >POST /api/v1/reserves >{ > "borrowernumber": 1234, > "biblionumber": 456, > "branchcode": "CPL", > "itemtype": "A" >} > >2/ Check that the hold was placed and the itemtype is correctly selected >3/ prove t/db_dependent/api/v1/reserves.t >--- > Koha/REST/V1/Reserve.pm | 4 +++- > api/v1/swagger.json | 4 ++++ > t/db_dependent/api/v1/reserves.t | 37 ++++++++++++++++++++++++++++++------- > 3 files changed, 37 insertions(+), 8 deletions(-) > >diff --git a/Koha/REST/V1/Reserve.pm b/Koha/REST/V1/Reserve.pm >index 69e6e98..cceb997 100644 >--- a/Koha/REST/V1/Reserve.pm >+++ b/Koha/REST/V1/Reserve.pm >@@ -49,6 +49,8 @@ sub add { > my $itemnumber = $body->{itemnumber}; > my $branchcode = $body->{branchcode}; > my $expirationdate = $body->{expirationdate}; >+ my $itemtype = $body->{itemtype}; >+ > my $borrower = Koha::Patrons->find($borrowernumber); > unless ($borrower) { > return $c->$cb({error => "Borrower not found"}, 404); >@@ -98,7 +100,7 @@ sub add { > > my $reserve_id = C4::Reserves::AddReserve($branchcode, $borrowernumber, > $biblionumber, undef, $priority, undef, $expirationdate, undef, >- $biblio->{title}, $itemnumber); >+ $biblio->{title}, $itemnumber, undef, $itemtype); > > unless ($reserve_id) { > return $c->$cb({ >diff --git a/api/v1/swagger.json b/api/v1/swagger.json >index b5c6d0a..7a9d281 100644 >--- a/api/v1/swagger.json >+++ b/api/v1/swagger.json >@@ -131,6 +131,10 @@ > "description": "Reserve end date", > "type": "string", > "format": "date" >+ }, >+ "itemtype": { >+ "description": "Limit reserve on one itemtype (ignored for item-level holds)", >+ "type": "string" > } > } > } >diff --git a/t/db_dependent/api/v1/reserves.t b/t/db_dependent/api/v1/reserves.t >index eeccbfd..02d18ae 100644 >--- a/t/db_dependent/api/v1/reserves.t >+++ b/t/db_dependent/api/v1/reserves.t >@@ -17,8 +17,9 @@ > > use Modern::Perl; > >-use Test::More tests => 30; >+use Test::More tests => 39; > use Test::Mojo; >+use t::lib::TestBuilder; > > use DateTime; > >@@ -38,6 +39,8 @@ my $t = Test::Mojo->new('Koha::REST::V1'); > > my $categorycode = Koha::Database->new()->schema()->resultset('Category')->first()->categorycode(); > my $branchcode = Koha::Database->new()->schema()->resultset('Branch')->first()->branchcode(); >+my $builder = t::lib::TestBuilder->new(); >+my $itemtype = $builder->build({ source => 'Itemtype' })->{ itemtype }; > > my $borrower = Koha::Patron->new; > $borrower->categorycode( $categorycode ); >@@ -54,7 +57,10 @@ $borrower2->store; > my $borrowernumber2 = $borrower2->borrowernumber; > > my $biblionumber = create_biblio('RESTful Web APIs'); >-my $itemnumber = create_item($biblionumber, 'TEST000001'); >+my $itemnumber = create_item($biblionumber, { >+ barcode => 'TEST000001', >+ itype => $itemtype >+}); > > my $reserve_id = C4::Reserves::AddReserve($branchcode, $borrowernumber, > $biblionumber, undef, 1, undef, undef, undef, '', $itemnumber); >@@ -126,6 +132,27 @@ $t->post_ok("/api/v1/reserves" => json => $post_data) > ->json_like('/error', qr/tooManyReserves/); > > >+$t->delete_ok("/api/v1/reserves/$reserve_id") >+ ->status_is(200); >+ >+$post_data = { >+ borrowernumber => int($borrowernumber), >+ biblionumber => int($biblionumber), >+ branchcode => $branchcode, >+ itemtype => $itemtype, >+}; >+ >+$t->post_ok("/api/v1/reserves" => json => $post_data) >+ ->status_is(201) >+ ->json_has('/reserve_id'); >+ >+$reserve_id = $t->tx->res->json->{reserve_id}; >+ >+$t->get_ok("/api/v1/reserves?borrowernumber=$borrowernumber") >+ ->status_is(200) >+ ->json_is('/0/reserve_id', $reserve_id) >+ ->json_is('/0/itemtype', $itemtype); >+ > $dbh->rollback; > > sub create_biblio { >@@ -142,11 +169,7 @@ sub create_biblio { > } > > sub create_item { >- my ($biblionumber, $barcode) = @_; >- >- my $item = { >- barcode => $barcode, >- }; >+ my ($biblionumber, $item) = @_; > > my $itemnumber = C4::Items::AddItem($item, $biblionumber); > >-- >1.9.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 16213
:
49951
|
50017
|
68179
|
70942
|
70943