Browse Source

Bug 14695 [QA Followup]

* Add tests for CanItemBeReserved returns 'itemAlreadyOnHold' to t/db_dependent/Holds.t
* Don't let GetReserveId explode
* Use search instead of map
* Remove instances of resbarcode
* Fix badly formed li closing tag

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
16.11.x
Kyle Hall 6 years ago
parent
commit
408c7bf001
  1. 2
      C4/Reserves.pm
  2. 12
      Koha/Holds.pm
  3. 2
      koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt
  4. 6
      koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
  5. 15
      t/db_dependent/Holds.t

2
C4/Reserves.pm

@ -2332,6 +2332,8 @@ sub GetReserveId {
my $hold = Koha::Holds->search( $params )->next();
return unless $hold;
return $hold->id();
}

12
Koha/Holds.pm

@ -71,15 +71,9 @@ that would prevent one or the other.
sub forced_hold_level {
my ($self) = @_;
my $force_hold_level;
if ( $self->count() ) {
my $has_item_level_holds;
map { $has_item_level_holds ||= $_->itemnumber } $self->as_list();
$force_hold_level = $has_item_level_holds ? 'item' : 'record';
}
return $force_hold_level;
return $self->search( { itemnumber => { '!=' => undef } } )->count()
? 'item'
: 'record';
}
=head3 type

2
koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt

@ -315,7 +315,6 @@ $(document).ready(function () {
<input type="hidden" name="itemnumber" value="[% itemnumber %]" />
<input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
<input type="hidden" name="biblionumber" value="[% itembiblionumber %]" />
<input type="hidden" name="resbarcode" value="[% barcode | html %]" />
<input type="hidden" name="reserve_id" value="[% reserve_id %]" />
<input type="hidden" name="diffBranch" value="[% destbranch %]" />
<input type="hidden" name="exemptfine" value="[% exemptfine %]" />
@ -532,7 +531,6 @@ $(document).ready(function () {
<input type="hidden" name="itemnumber" value="[% itemnumber %]" />
<input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
<input type="hidden" name="biblionumber" value="[% itembiblionumber %]" />
<input type="hidden" name="resbarcode" value="[% barcode %]" />
<input type="hidden" name="reserve_id" value="[% reserve_id %]" />
<input type="hidden" name="diffBranch" value="[% destbranch %]" />
<input type="hidden" name="exemptfine" value="[% exemptfine %]" />

6
koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt

@ -276,13 +276,13 @@ function checkMultiHold() {
[% ELSIF ( exceeded_holds_per_record ) %]
<li><strong>Too many holds for this record: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> can only place a maximum of [% max_holds_for_record %] hold(s) on this record.</li>
[% ELSIF ( alreadypossession ) %]
<li> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>is already in possession</strong> of one item</lie
<li> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>is already in possession</strong> of one item.</li>
[% ELSIF ( alreadyreserved ) %]
<li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>already has a hold</strong> on this item </li>
<li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %]</a> <strong>already has a hold</strong> on this item.</li>
[% ELSIF ( ageRestricted ) %]
<li><strong>Age restricted</strong></li>
[% ELSIF ( none_available ) %]
<li> <strong>No items are available</strong> to be placed on hold</li>
<li> <strong>No items are available</strong> to be placed on hold.</li>
[% ELSIF ( maxreserves ) %]
<li><strong>Too many holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrowernumber %]">[% borrowerfirstname %] [% borrowersurname %] </a> has too many holds.</li>
[% END %]

15
t/db_dependent/Holds.t

@ -8,7 +8,7 @@ use t::lib::TestBuilder;
use C4::Context;
use C4::Branch;
use Test::More tests => 60;
use Test::More tests => 61;
use MARC::Record;
use C4::Biblio;
use C4::Items;
@ -339,6 +339,19 @@ ModItem({ damaged => 1 }, $item_bibnum, $itemnumber);
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 1 );
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber), 'OK', "Patron can reserve damaged item with AllowHoldsOnDamagedItems enabled" );
ok( defined( ( CheckReserves($itemnumber) )[1] ), "Hold can be trapped for damaged item with AllowHoldsOnDamagedItems enabled" );
$hold = Koha::Hold->new(
{
borrowernumber => $borrowernumbers[0],
itemnumber => $itemnumber,
biblionumber => $item_bibnum,
}
)->store();
is( CanItemBeReserved( $borrowernumbers[0], $itemnumber ),
'itemAlreadyOnHold',
"Patron cannot place a second item level hold for a given item" );
$hold->delete();
t::lib::Mocks::mock_preference( 'AllowHoldsOnDamagedItems', 0 );
ok( CanItemBeReserved( $borrowernumbers[0], $itemnumber) eq 'damaged', "Patron cannot reserve damaged item with AllowHoldsOnDamagedItems disabled" );
ok( !defined( ( CheckReserves($itemnumber) )[1] ), "Hold cannot be trapped for damaged item with AllowHoldsOnDamagedItems disabled" );

Loading…
Cancel
Save