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 957-963 subtest 'Koha::Hold::item_group tests' => sub { Link Here
957
957
958
subtest 'change_type tests' => sub {
958
subtest 'change_type tests' => sub {
959
959
960
    plan tests => 9;
960
    plan tests => 13;
961
961
962
    $schema->storage->txn_begin;
962
    $schema->storage->txn_begin;
963
963
Lines 966-971 subtest 'change_type tests' => sub { Link Here
966
        class => 'Koha::Holds',
966
        class => 'Koha::Holds',
967
        value => {
967
        value => {
968
            itemnumber => undef,
968
            itemnumber => undef,
969
            item_level_hold => 0,
969
        }
970
        }
970
    } );
971
    } );
971
972
Lines 982-1005 subtest 'change_type tests' => sub { Link Here
982
983
983
    is( $hold->itemnumber, undef, 'record hold to record hold, no changes');
984
    is( $hold->itemnumber, undef, 'record hold to record hold, no changes');
984
985
986
    is( $hold->item_level_hold, 0, 'item_level_hold=0' );
987
985
    ok( $hold->change_type( $item->itemnumber ) );
988
    ok( $hold->change_type( $item->itemnumber ) );
986
989
987
    $hold->discard_changes;
990
    $hold->discard_changes;
988
991
989
    is( $hold->itemnumber, $item->itemnumber, 'record hold to item hold');
992
    is( $hold->itemnumber, $item->itemnumber, 'record hold to item hold');
990
993
994
    is( $hold->item_level_hold, 1, 'item_level_hold=1' );
995
991
    ok( $hold->change_type( $item->itemnumber ) );
996
    ok( $hold->change_type( $item->itemnumber ) );
992
997
993
    $hold->discard_changes;
998
    $hold->discard_changes;
994
999
995
    is( $hold->itemnumber, $item->itemnumber, 'item hold to item hold, no changes');
1000
    is( $hold->itemnumber, $item->itemnumber, 'item hold to item hold, no changes');
996
1001
1002
    is( $hold->item_level_hold, 1, 'item_level_hold=1' );
1003
997
    ok( $hold->change_type );
1004
    ok( $hold->change_type );
998
1005
999
    $hold->discard_changes;
1006
    $hold->discard_changes;
1000
1007
1001
    is( $hold->itemnumber, undef, 'item hold to record hold');
1008
    is( $hold->itemnumber, undef, 'item hold to record hold');
1002
1009
1010
    is( $hold->item_level_hold, 0, 'item_level_hold=0' );
1011
1003
    my $hold3 = $builder->build_object( {
1012
    my $hold3 = $builder->build_object( {
1004
        class => 'Koha::Holds',
1013
        class => 'Koha::Holds',
1005
        value => {
1014
        value => {
1006
- 

Return to bug 31692