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

(-)a/Koha/Items.pm (-2 / +2 lines)
Lines 68-74 sub filter_by_for_hold { Link Here
68
        }
68
        }
69
    );
69
    );
70
    my @hold_not_allowed_itypes;
70
    my @hold_not_allowed_itypes;
71
    if ( $default_rule ) {
71
    if ($default_rule) {
72
        @hold_not_allowed_itypes = Koha::ItemTypes->search->get_column('itemtype');
72
        @hold_not_allowed_itypes = Koha::ItemTypes->search->get_column('itemtype');
73
        my @hold_allowed_itypes = Koha::CirculationRules->search(
73
        my @hold_allowed_itypes = Koha::CirculationRules->search(
74
            {
74
            {
Lines 78-84 sub filter_by_for_hold { Link Here
78
                categorycode => undef,
78
                categorycode => undef,
79
            }
79
            }
80
        )->get_column('itemtype');
80
        )->get_column('itemtype');
81
        @hold_not_allowed_itypes = array_minus( @hold_not_allowed_itypes, @hold_allowed_itypes )
81
        @hold_not_allowed_itypes = array_minus( @hold_not_allowed_itypes, @hold_allowed_itypes );
82
    } else {
82
    } else {
83
        @hold_not_allowed_itypes = Koha::CirculationRules->search(
83
        @hold_not_allowed_itypes = Koha::CirculationRules->search(
84
            {
84
            {
(-)a/t/db_dependent/Koha/Holds.t (-2 / +2 lines)
Lines 535-542 subtest 'get_items_that_can_fill' => sub { Link Here
535
535
536
    Koha::CirculationRules->search(
536
    Koha::CirculationRules->search(
537
        {
537
        {
538
            rule_name    => 'holdallowed',
538
            rule_name  => 'holdallowed',
539
            rule_value   => 'not_allowed',
539
            rule_value => 'not_allowed',
540
        }
540
        }
541
    )->delete;
541
    )->delete;
542
542
(-)a/t/db_dependent/Koha/Items.t (-6 / +7 lines)
Lines 2011-2020 subtest 'filter_by_for_hold' => sub { Link Here
2011
            rule_value => 'not_allowed',
2011
            rule_value => 'not_allowed',
2012
        }
2012
        }
2013
    );
2013
    );
2014
    my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' });
2014
    my $itemtype              = $builder->build_object( { class => 'Koha::ItemTypes' } );
2015
    my $not_holdable_itemtype = $itemtype->itemtype;
2015
    my $not_holdable_itemtype = $itemtype->itemtype;
2016
    my $itemtype2 = $builder->build_object({ class => 'Koha::ItemTypes' });
2016
    my $itemtype2             = $builder->build_object( { class => 'Koha::ItemTypes' } );
2017
    my $holdable_itemtype = $itemtype2->itemtype;
2017
    my $holdable_itemtype     = $itemtype2->itemtype;
2018
    Koha::CirculationRules->set_rule(
2018
    Koha::CirculationRules->set_rule(
2019
        {
2019
        {
2020
            branchcode => undef,
2020
            branchcode => undef,
Lines 2028-2036 subtest 'filter_by_for_hold' => sub { Link Here
2028
    my $library = $builder->build_object({ class => 'Koha::Libraries' });
2028
    my $library = $builder->build_object({ class => 'Koha::Libraries' });
2029
    t::lib::Mocks::mock_preference('IndependentBranches', 0); # more robust tests
2029
    t::lib::Mocks::mock_preference('IndependentBranches', 0); # more robust tests
2030
    is( $biblio->items->filter_by_for_hold->count, 0, 'no item yet' );
2030
    is( $biblio->items->filter_by_for_hold->count, 0, 'no item yet' );
2031
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 0, itype => $not_holdable_itemtype } );
2031
    $builder->build_sample_item(
2032
        { biblionumber => $biblio->biblionumber, notforloan => 0, itype => $not_holdable_itemtype } );
2032
    is( $biblio->items->filter_by_for_hold->count, 0, 'default rule prevents hold' );
2033
    is( $biblio->items->filter_by_for_hold->count, 0, 'default rule prevents hold' );
2033
    $builder->build_sample_item( { biblionumber => $biblio->biblionumber, notforloan => 0, itype => $holdable_itemtype } );
2034
    $builder->build_sample_item(
2035
        { biblionumber => $biblio->biblionumber, notforloan => 0, itype => $holdable_itemtype } );
2034
    is( $biblio->items->filter_by_for_hold->count, 1, 'hold allowed despite default rule' );
2036
    is( $biblio->items->filter_by_for_hold->count, 1, 'hold allowed despite default rule' );
2035
2037
2036
    # Reset items and circ rules to remove default rule
2038
    # Reset items and circ rules to remove default rule
2037
- 

Return to bug 29087