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

(-)a/Koha/Hold.pm (-1 / +4 lines)
Lines 869-875 sub change_type { Link Here
869
    }
869
    }
870
870
871
    if ( $record_holds_per_patron->count == 1 ) {
871
    if ( $record_holds_per_patron->count == 1 ) {
872
        $self->set({ itemnumber => $itemnumber ? $itemnumber : undef })->store;
872
        $self->set({
873
            itemnumber => $itemnumber ? $itemnumber : undef,
874
            item_level_hold => $itemnumber ? 1 : 0,
875
        })->store;
873
    } else {
876
    } else {
874
        Koha::Exceptions::Hold::CannotChangeHoldType->throw();
877
        Koha::Exceptions::Hold::CannotChangeHoldType->throw();
875
    }
878
    }
(-)a/t/db_dependent/Koha/Hold.t (-2 / +10 lines)
Lines 958-964 subtest 'Koha::Hold::item_group tests' => sub { Link Here
958
958
959
subtest 'change_type tests' => sub {
959
subtest 'change_type tests' => sub {
960
960
961
    plan tests => 9;
961
    plan tests => 13;
962
962
963
    $schema->storage->txn_begin;
963
    $schema->storage->txn_begin;
964
964
Lines 967-972 subtest 'change_type tests' => sub { Link Here
967
        class => 'Koha::Holds',
967
        class => 'Koha::Holds',
968
        value => {
968
        value => {
969
            itemnumber => undef,
969
            itemnumber => undef,
970
            item_level_hold => 0,
970
        }
971
        }
971
    } );
972
    } );
972
973
Lines 983-1006 subtest 'change_type tests' => sub { Link Here
983
984
984
    is( $hold->itemnumber, undef, 'record hold to record hold, no changes');
985
    is( $hold->itemnumber, undef, 'record hold to record hold, no changes');
985
986
987
    is( $hold->item_level_hold, 0, 'item_level_hold=0' );
988
986
    ok( $hold->change_type( $item->itemnumber ) );
989
    ok( $hold->change_type( $item->itemnumber ) );
987
990
988
    $hold->discard_changes;
991
    $hold->discard_changes;
989
992
990
    is( $hold->itemnumber, $item->itemnumber, 'record hold to item hold');
993
    is( $hold->itemnumber, $item->itemnumber, 'record hold to item hold');
991
994
995
    is( $hold->item_level_hold, 1, 'item_level_hold=1' );
996
992
    ok( $hold->change_type( $item->itemnumber ) );
997
    ok( $hold->change_type( $item->itemnumber ) );
993
998
994
    $hold->discard_changes;
999
    $hold->discard_changes;
995
1000
996
    is( $hold->itemnumber, $item->itemnumber, 'item hold to item hold, no changes');
1001
    is( $hold->itemnumber, $item->itemnumber, 'item hold to item hold, no changes');
997
1002
1003
    is( $hold->item_level_hold, 1, 'item_level_hold=1' );
1004
998
    ok( $hold->change_type );
1005
    ok( $hold->change_type );
999
1006
1000
    $hold->discard_changes;
1007
    $hold->discard_changes;
1001
1008
1002
    is( $hold->itemnumber, undef, 'item hold to record hold');
1009
    is( $hold->itemnumber, undef, 'item hold to record hold');
1003
1010
1011
    is( $hold->item_level_hold, 0, 'item_level_hold=0' );
1012
1004
    my $hold3 = $builder->build_object( {
1013
    my $hold3 = $builder->build_object( {
1005
        class => 'Koha::Holds',
1014
        class => 'Koha::Holds',
1006
        value => {
1015
        value => {
1007
- 

Return to bug 31692