Bugzilla – Attachment 70409 Details for
Bug 19945
ILSDI - Return the reason a reserve is impossible
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19945 - ILSDI - Return the reason a reserve is impossible
Bug-19945---ILSDI---Return-the-reason-a-reserve-is.patch (text/plain), 5.13 KB, created by
Alex Arnaud
on 2018-01-10 15:38:56 UTC
(
hide
)
Description:
Bug 19945 - ILSDI - Return the reason a reserve is impossible
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2018-01-10 15:38:56 UTC
Size:
5.13 KB
patch
obsolete
>From b593a7bbd2ebd8830a9f51e509fd85d2e554f76e Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Wed, 10 Jan 2018 15:31:54 +0000 >Subject: [PATCH] Bug 19945 - ILSDI - Return the reason a reserve is impossible > >Currently, the ILDSI services HoldTitle and HoldItem always return a >"NotHoldable" code is the reserve is impossible. We need to know why > >Test plan: > > - Apply this patch > - Place a hold on a non reservable title using ILS-DI web service > (http://koha-opac.example.org/cgi-bin/koha/ilsdi.pl?service=HoldTitle&patron_id=1&bib_id=1&request_location=) > - you should get the reason instead of NotHoldable, > - Place a hold on a non reservable item using ILS-DI web service > (http://koha-opac.example.org/cgi-bin/koha/ilsdi.pl?service=HoldItem&patron_id=1&bib_id=1&item_id=1) > - you should get the reason instead of NotHoldable, >--- > C4/ILSDI/Services.pm | 6 ++- > t/db_dependent/ILSDI_Services.t | 95 ++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 98 insertions(+), 3 deletions(-) > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index e7b3bca..3d58be8 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -642,7 +642,8 @@ sub HoldTitle { > my $title = $biblio ? $biblio->title : ''; > > # Check if the biblio can be reserved >- return { code => 'NotHoldable' } unless CanBookBeReserved( $borrowernumber, $biblionumber ) eq 'OK'; >+ my $code = CanBookBeReserved( $borrowernumber, $biblionumber ); >+ return { code => $code } unless ( $code eq 'OK' ); > > my $branch; > >@@ -720,7 +721,8 @@ sub HoldItem { > # Check for item disponibility > my $canitembereserved = C4::Reserves::CanItemBeReserved( $borrowernumber, $itemnumber ); > my $canbookbereserved = C4::Reserves::CanBookBeReserved( $borrowernumber, $biblionumber ); >- return { code => 'NotHoldable' } unless $canbookbereserved eq 'OK' and $canitembereserved eq 'OK'; >+ return { code => $canitembereserved } unless $canitembereserved eq 'OK'; >+ return { code => $canbookbereserved } unless $canbookbereserved eq 'OK'; > > # Pickup branch management > my $branch; >diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t >index 7677db0..bcd4155 100644 >--- a/t/db_dependent/ILSDI_Services.t >+++ b/t/db_dependent/ILSDI_Services.t >@@ -19,7 +19,7 @@ use Modern::Perl; > > use CGI qw ( -utf8 ); > >-use Test::More tests => 3; >+use Test::More tests => 4; > use Test::MockModule; > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -198,3 +198,96 @@ subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes > $schema->storage->txn_rollback; > }; > >+subtest 'Holds test' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 0 ); >+ >+ my $patron = $builder->build({ >+ source => 'Borrower', >+ }); >+ >+ my $biblio = $builder->build({ >+ source => 'Biblio', >+ }); >+ >+ my $biblioitems = $builder->build({ >+ source => 'Biblioitem', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ } >+ }); >+ >+ my $item = $builder->build({ >+ source => 'Item', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ damaged => 1 >+ } >+ }); >+ >+ my $query = new CGI; >+ $query->param( 'patron_id', $patron->{borrowernumber}); >+ $query->param( 'bib_id', $biblio->{biblionumber}); >+ >+ my $reply = C4::ILSDI::Services::HoldTitle( $query ); >+ is( $reply->{code}, 'damaged', "Item damaged" ); >+ >+ my $item_o = Koha::Items->find($item->{itemnumber}); >+ $item_o->damaged(0)->store; >+ >+ my $hold = $builder->build({ >+ source => 'Reserve', >+ value => { >+ borrowernumber => $patron->{borrowernumber}, >+ biblionumber => $biblio->{biblionumber}, >+ itemnumber => $item->{itemnumber} >+ } >+ }); >+ >+ $reply = C4::ILSDI::Services::HoldTitle( $query ); >+ is( $reply->{code}, 'itemAlreadyOnHold', "Item already on hold" ); >+ >+ my $biblio2 = $builder->build({ >+ source => 'Biblio', >+ }); >+ >+ my $biblioitems2 = $builder->build({ >+ source => 'Biblioitem', >+ value => { >+ biblionumber => $biblio2->{biblionumber}, >+ } >+ }); >+ >+ my $item2 = $builder->build({ >+ source => 'Item', >+ value => { >+ biblionumber => $biblio2->{biblionumber}, >+ damaged => 0 >+ } >+ }); >+ >+ t::lib::Mocks::mock_preference( 'ReservesControlBranch', 'PatronLibrary' ); >+ my $issuingrule = $builder->build({ >+ source => 'Issuingrule', >+ value => { >+ categorycode => $patron->{categorycode}, >+ itemtype => $item2->{itype}, >+ branchcode => $patron->{branchcode}, >+ reservesallowed => 0, >+ } >+ }); >+ >+ $query = new CGI; >+ $query->param( 'patron_id', $patron->{borrowernumber}); >+ $query->param( 'bib_id', $biblio2->{biblionumber}); >+ $query->param( 'item_id', $item2->{itemnumber}); >+ >+ $reply = C4::ILSDI::Services::HoldItem( $query ); >+ is( $reply->{code}, 'tooManyReserves', "Too many reserves" ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >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 19945
:
70409
|
73351
|
73352
|
75688
|
75689
|
79046
|
79047
|
79048
|
79049
|
81371
|
81372
|
81373
|
81374
|
83745
|
83746
|
83747
|
83748