Bugzilla – Attachment 89725 Details for
Bug 22899
Cannot view course details
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22899: Add pending_hold method to Koha::Item
Bug-22899-Add-pendinghold-method-to-KohaItem.patch (text/plain), 3.03 KB, created by
Hayley Pelham
on 2019-05-14 05:29:34 UTC
(
hide
)
Description:
Bug 22899: Add pending_hold method to Koha::Item
Filename:
MIME Type:
Creator:
Hayley Pelham
Created:
2019-05-14 05:29:34 UTC
Size:
3.03 KB
patch
obsolete
>From 910c8921b185b51c323756ace9f474f82e8a2700 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 13 May 2019 20:09:05 +0000 >Subject: [PATCH] Bug 22899: Add pending_hold method to Koha::Item > >To test: > 1 - Enable course reserves > 2 - Create a course > 3 - Add an item to the course > 4 - Attempt to view the course on the OPAC > 5 - Internal Server Error > 6 - Apply patch > 7 - Add an item to the holds queue by placing a hold and running holds queue builder or: > INSERT INTO tmp_holdsqueue (itemnumber) VALUES (###); > 8 - View the course page, note item appears 'Pending hold' > 9 - Remove the holdsqueue line >10 - View the course page, note item appears 'Available' >11 - prove -v t/db_dependent/Koha/Item.t > >Signed-off-by: Hayley Mapley <hayleymapley@catalyst.net.nz> >I see Jonathan's comments about small improvements, but will sign off as >everything works as expected here. >--- > Koha/Item.pm | 14 ++++++++++++++ > t/db_dependent/Koha/Item.t | 23 ++++++++++++++++++++++- > 2 files changed, 36 insertions(+), 1 deletion(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 49ae8e16f3..f97634bd2e 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -354,6 +354,20 @@ sub add_to_rota { > return $self; > } > >+=head3 pending_hold >+ >+ my $is_pending_hold = $item->pending_hold(); >+ >+This method checks the tmp_holdsqueue to see if this item has been selected for a hold, but not filled yet and returns true or false >+ >+=cut >+ >+sub pending_hold { >+ my ( $self ) = @_; >+ my $pending_hold = $self->_result->tmp_holdsqueues; >+ return !C4::Context->preference('AllowItemsOnHoldCheckout') && $pending_hold->count ? 1: 0; >+} >+ > =head2 Internal methods > > =head3 _type >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index f20c2e7c33..f7b652cc65 100644 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 1; >+use Test::More tests => 2; > > use Koha::Items; > use Koha::Database; >@@ -61,3 +61,24 @@ subtest 'hidden_in_opac() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'pending_hold() tests' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $dbh = C4::Context->dbh; >+ my $item = $builder->build_sample_item({ itemlost => 0 }); >+ my $itemnumber = $item->itemnumber; >+ >+ # disable AllowItemsOnHoldCheckout as it ignores pending holds >+ t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 0 ); >+ $dbh->do("INSERT INTO tmp_holdsqueue (surname,borrowernumber,itemnumber) VALUES ('Clamp',42,$itemnumber)"); >+ ok( $item->pending_hold, "Yes, we have a pending hold"); >+ t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 1 ); >+ ok( !$item->pending_hold, "We don't consider a pending hold if hold items can be checked out"); >+ t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 0 ); >+ $dbh->do("DELETE FROM tmp_holdsqueue WHERE itemnumber=$itemnumber"); >+ ok( !$item->pending_hold, "We don't have a pending hold if nothing in the tmp_holdsqueue"); >+}; >-- >2.11.0
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 22899
:
89706
|
89707
|
89708
|
89709
|
89725
|
89736
|
89737
|
89738
|
89739
|
89740