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

(-)a/C4/Reserves.pm (-1 / +1 lines)
Lines 189-195 sub AddReserve { Link Here
189
            && ( $item->damaged && C4::Context->preference('AllowHoldsOnDamagedItems') || !$item->damaged )
189
            && ( $item->damaged && C4::Context->preference('AllowHoldsOnDamagedItems') || !$item->damaged )
190
190
191
            # Lastly, if this already has holds, we shouldn't make it waiting for the new hold
191
            # Lastly, if this already has holds, we shouldn't make it waiting for the new hold
192
            && !$item->holds->count )
192
            && !$item->current_holds->count )
193
        {
193
        {
194
            $priority = 0;
194
            $priority = 0;
195
            $found = 'W';
195
            $found = 'W';
(-)a/t/db_dependent/Reserves.t (-6 / +24 lines)
Lines 664-670 subtest '_koha_notify_reserve() tests' => sub { Link Here
664
};
664
};
665
665
666
subtest 'ReservesNeedReturns' => sub {
666
subtest 'ReservesNeedReturns' => sub {
667
    plan tests => 13;
667
    plan tests => 18;
668
668
669
    my $library    = $builder->build_object( { class => 'Koha::Libraries' } );
669
    my $library    = $builder->build_object( { class => 'Koha::Libraries' } );
670
    my $item_info  = {
670
    my $item_info  = {
Lines 723-736 subtest 'ReservesNeedReturns' => sub { Link Here
723
    $hold->delete;
723
    $hold->delete;
724
    $hold_1->delete;
724
    $hold_1->delete;
725
725
726
    $builder->build({ source => "Branchtransfer", value => {
726
    my $transfer = $builder->build_object({
727
        itemnumber  => $item->itemnumber,
727
        class => "Koha::Item::Transfers",
728
        datearrived => undef,
728
        value => {
729
    } });
729
          itemnumber  => $item->itemnumber,
730
          datearrived => undef,
731
        }
732
    });
730
    $item->damaged(0)->store;
733
    $item->damaged(0)->store;
731
    $hold = place_item_hold( $patron, $item, $library, $priority );
734
    $hold = place_item_hold( $patron, $item, $library, $priority );
732
    is( $hold->found, undef, 'If ReservesNeedReturns is 0 but item in transit the hold must not be set to waiting' );
735
    is( $hold->found, undef, 'If ReservesNeedReturns is 0 but item in transit the hold must not be set to waiting' );
733
    is( $hold->priority, 1,  'If ReservesNeedReturns is 0 but item in transit the hold must not be set to waiting' );
736
    is( $hold->priority, 1,  'If ReservesNeedReturns is 0 but item in transit the hold must not be set to waiting' );
737
    $hold->delete;
738
    $transfer->delete;
739
740
    $hold = place_item_hold( $patron, $item, $library, $priority );
741
    is( $hold->priority, 0, 'If ReservesNeedReturns is 0 and no other status, priority must have been set to 0' );
742
    is( $hold->found, 'W', 'If ReservesNeedReturns is 0 and no other status, found must have been set waiting' );
743
    $hold_1 = place_item_hold( $patron, $item, $library, $priority );
744
    is( $hold_1->priority, 1, 'If ReservesNeedReturns is 0 but item has a hold priority is 1' );
745
    $hold_1->suspend(1)->store; # We suspend the hold
746
    $hold->delete; # Delete the waiting hold
747
    $hold = place_item_hold( $patron, $item, $library, $priority );
748
    is( $hold->priority, 0, 'If ReservesNeedReturns is 0 and other hold(s) suspended, priority must have been set to 0' );
749
    is( $hold->found, 'W', 'If ReservesNeedReturns is 0 and other  hold(s) suspended, found must have been set waiting' );
750
751
752
734
753
735
    t::lib::Mocks::mock_preference('ReservesNeedReturns', 1); # Don't affect other tests
754
    t::lib::Mocks::mock_preference('ReservesNeedReturns', 1); # Don't affect other tests
736
};
755
};
737
- 

Return to bug 23964