Bugzilla – Attachment 44064 Details for
Bug 14155
Placing holds via ILSDI bypass some checks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14155 - Update tests and fix failures
Bug-14155---Update-tests-and-fix-failures.patch (text/plain), 4.96 KB, created by
Alex Arnaud
on 2015-10-27 13:45:20 UTC
(
hide
)
Description:
Bug 14155 - Update tests and fix failures
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2015-10-27 13:45:20 UTC
Size:
4.96 KB
patch
obsolete
>From 40bc12f626794e73ec3f53a34a82ca93de28dc38 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Tue, 27 Oct 2015 14:37:23 +0100 >Subject: [PATCH] Bug 14155 - Update tests and fix failures > >--- > C4/ILSDI/Services.pm | 4 ++-- > C4/Reserves.pm | 2 +- > t/db_dependent/ILSDI_Services.t | 32 +++++++++++++++++++++++++++++++- > t/db_dependent/Reserves.t | 18 +++++++++++------- > 4 files changed, 45 insertions(+), 11 deletions(-) > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index 1a45e36..2888e40 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -613,7 +613,7 @@ sub HoldTitle { > return { code => 'NotHoldable' } if AlreadyReserved($biblionumber, $borrowernumber); > > # Check if the biblio can be reserved >- return { code => 'NotHoldable' } unless CanBookBeReserved( $borrowernumber, $biblionumber ) eq 'OK'; >+ return { code => 'NotHoldable' } unless C4::Reserves::CanBookBeReserved( $borrowernumber, $biblionumber ) eq 'OK'; > > my $branch; > >@@ -628,7 +628,7 @@ sub HoldTitle { > > # Add the reserve > # $branch, $borrowernumber, $biblionumber, >- # $constraint, $bibitems, $priority, $resdate, $expdate, $notes, >+ # $bibitems, $priority, $resdate, $expdate, $notes, > # $title, $checkitem, $found > my $priority= C4::Reserves::CalculatePriority( $biblionumber ); > AddReserve( $branch, $borrowernumber, $biblionumber, undef, $priority, undef, undef, undef, $title, undef, undef ); >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 1ea152e..e563706 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -1060,7 +1060,7 @@ sub ReachedMaxReserves { > > return 0 unless C4::Context->preference('maxreserves'); > >- if ( $number_reserves + $number_wanted >= C4::Context->preference('maxreserves') ) { >+ if ( $number_reserves + $number_wanted > C4::Context->preference('maxreserves') ) { > return 1; > } > >diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t >index 473c826..bcecad6 100644 >--- a/t/db_dependent/ILSDI_Services.t >+++ b/t/db_dependent/ILSDI_Services.t >@@ -25,6 +25,22 @@ $dbh->{RaiseError} = 1; > my $maxallowedreserves = 3; > t::lib::Mocks::mock_preference('maxreserves', $maxallowedreserves); > >+my $context = new Test::MockModule('C4::Context'); >+mock_marcfromkohafield(); >+ >+my $reserves_module = new Test::MockModule('C4::Reserves'); >+$reserves_module->mock('CanBookBeReserved', >+ sub { >+ return 'OK'; >+ } >+); >+ >+$reserves_module->mock('CanItemBeReserved', >+ sub { >+ return 'OK'; >+ } >+); >+ > # Create patron > my %data = ( > firstname => 'my firstname', >@@ -71,7 +87,7 @@ my %item_branch_infos = ( > ); > > my $record = MARC::Record->new; >-my $title = MARC::Field->new('200','','','a' => 'Hello world.'); >+my $title = MARC::Field->new('245','','','a' => 'Hello world.'); > $record->append_fields($title); > > my ($biblionumber) = AddBiblio($record, ''); >@@ -163,3 +179,17 @@ my $itemnumber4 = AddItem({ barcode => '0401', %item_branch_infos }, $biblionumb > $reply = C4::ILSDI::Services::HoldItem($query); > is($reply->{'pickup_location'}, 'Unit test library', 'Joe John hold an item - ILSDI'); > } >+ >+sub mock_marcfromkohafield { >+ >+ $context->mock('marcfromkohafield', >+ sub { >+ return { >+ '' => { >+ 'biblio.title' => [ '245', 'a' ], >+ 'biblio.biblionumber' => [ '999', 'c' ], >+ 'biblioitems.biblioitemnumber' => [ '999', 'd' ] >+ } >+ }; >+ }); >+} >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index f85fe4a..3618ff9 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 77; >+use Test::More tests => 79; > use Test::Warn; > > use MARC::Record; >@@ -168,13 +168,17 @@ t::lib::Mocks::mock_preference('maxreserves', 3); > > ok(!ReachedMaxReserves($borrowernumber), 'First borrower doesn\'t reached max reserves'); > >-AddReserve($branch, $borrowernumber, $miniaturist_id, >- $constraint, $bibitems, $priority, $resdate, $expdate, $notes, >- $title_14155a, $checkitem, $found); >+ok(!ReachedMaxReserves($borrowernumber, 2), 'First borrower asking for 2 documents doesn\'t reached max reserves'); > >-AddReserve($branch, $borrowernumber, $broken_id, >- $constraint, $bibitems, $priority, $resdate, $expdate, $notes, >- $title_14155b, $checkitem, $found); >+ok(ReachedMaxReserves($borrowernumber, 3), 'First borrower asking for 3 documents reached max reserves'); >+ >+AddReserve($branch, $borrowernumber, $miniaturist_id, >+ $bibitems, $priority, $resdate, $expdate, $notes, >+ $title_14155a, $checkitem, $found); >+ >+AddReserve($branch, $borrowernumber, $broken_id, >+ $bibitems, $priority, $resdate, $expdate, $notes, >+ $title_14155b, $checkitem, $found); > > ok(ReachedMaxReserves($borrowernumber), 'First borrower reached max reserves'); > >-- >1.7.10.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 14155
:
38884
|
40170
|
40174
|
40175
|
40176
|
40208
|
40210
|
40239
|
40240
|
40241
|
44047
|
44048
|
44049
|
44050
| 44064