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

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

Return to bug 16787