View | Details | Raw Unified | Return to bug 16787
Collapse All | Expand All

(-)a/C4/Reserves.pm (+3 lines)
Lines 378-383 sub CanItemBeReserved { Link Here
378
            found          => undef, # Found holds don't count against a patron's holds limit
378
            found          => undef, # Found holds don't count against a patron's holds limit
379
        }
379
        }
380
    );
380
    );
381
    if ( $holds_per_record == 0 ) {
382
        return "noReservesAllowed";
383
    }
381
    if ( $holds->count() >= $holds_per_record ) {
384
    if ( $holds->count() >= $holds_per_record ) {
382
        return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record };
385
        return { status => "tooManyHoldsForThisRecord", limit => $holds_per_record };
383
    }
386
    }
(-)a/t/db_dependent/Holds.t (-2 / +12 lines)
Lines 336-344 subtest 'CanItemBeReserved' => sub { Link Here
336
        q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record) VALUES (?, ?, ?, ?, ?)}, {},
336
        q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record) VALUES (?, ?, ?, ?, ?)}, {},
337
        '*', '*', $itemtype_can, 2, 2
337
        '*', '*', $itemtype_can, 2, 2
338
    );
338
    );
339
    $dbh->do(
340
        q{INSERT INTO issuingrules (categorycode, branchcode, itemtype, reservesallowed, holds_per_record) VALUES (?, ?, ?, ?, ?)}, {},
341
        '*', '*', 'CANNOT_RECORD', 0, 0
342
    );
339
343
340
    subtest 'noReservesAllowed' => sub {
344
    subtest 'noReservesAllowed' => sub {
341
        plan tests => 4;
345
        plan tests => 5;
342
346
343
        my $biblionumber_cannot = $builder->build_sample_biblio({ itemtype => $itemtype_cant })->biblionumber;
347
        my $biblionumber_cannot = $builder->build_sample_biblio({ itemtype => $itemtype_cant })->biblionumber;
344
        my $biblionumber_can = $builder->build_sample_biblio({ itemtype => $itemtype_can })->biblionumber;
348
        my $biblionumber_can = $builder->build_sample_biblio({ itemtype => $itemtype_can })->biblionumber;
Lines 348-353 subtest 'CanItemBeReserved' => sub { Link Here
348
        my ( undef, undef, $itemnumber_2_can ) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CAN' } , $biblionumber_can);
352
        my ( undef, undef, $itemnumber_2_can ) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CAN' } , $biblionumber_can);
349
        my ( undef, undef, $itemnumber_2_cannot ) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $biblionumber_can);
353
        my ( undef, undef, $itemnumber_2_cannot ) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT' } , $biblionumber_can);
350
354
355
        my ($biblionumber_record_cannot) = create_helper_biblio('CANNOT_RECORD');
356
        my ( undef, undef, $itemnumber_3_cannot ) = AddItem({ homebranch => $branch_1, holdingbranch => $branch_1, itype => 'CANNOT_RECORD' } , $biblionumber_record_cannot);
357
351
        Koha::Holds->search({borrowernumber => $borrowernumbers[0]})->delete;
358
        Koha::Holds->search({borrowernumber => $borrowernumbers[0]})->delete;
352
359
353
        t::lib::Mocks::mock_preference('item-level_itypes', 1);
360
        t::lib::Mocks::mock_preference('item-level_itypes', 1);
Lines 368-373 subtest 'CanItemBeReserved' => sub { Link Here
368
            CanItemBeReserved( $borrowernumbers[0], $itemnumber_2_cannot), 'OK',
375
            CanItemBeReserved( $borrowernumbers[0], $itemnumber_2_cannot), 'OK',
369
            "With biblio level set, rule from biblio must be picked (CAN)"
376
            "With biblio level set, rule from biblio must be picked (CAN)"
370
        );
377
        );
378
        is(
379
            CanItemBeReserved( $borrowernumbers[0], $itemnumber_3_cannot), 'noReservesAllowed',
380
            "When no holds allowed and no holds per record allowed should return noReservesAllowed"
381
        );
371
    };
382
    };
372
383
373
    subtest 'tooManyHoldsForThisRecord + tooManyReserves + itemAlreadyOnHold' => sub {
384
    subtest 'tooManyHoldsForThisRecord + tooManyReserves + itemAlreadyOnHold' => sub {
374
- 

Return to bug 16787