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

(-)a/Koha/Item.pm (+6 lines)
Lines 234-241 sub delete { Link Here
234
    # FIXME check the item has no current issues
234
    # FIXME check the item has no current issues
235
    # i.e. raise the appropriate exception
235
    # i.e. raise the appropriate exception
236
236
237
    # Get the item group so we can delete it later if it has no items left
238
    my $item_group = C4::Context->preference('EnableItemGroups') ? $self->item_group : undef;
239
237
    my $result = $self->SUPER::delete;
240
    my $result = $self->SUPER::delete;
238
241
242
    # Delete the item gorup if it has no items left
243
    $item_group->delete if ( $item_group && $item_group->items->count == 0 );
244
239
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
245
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
240
    $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
246
    $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
241
        unless $params->{skip_record_index};
247
        unless $params->{skip_record_index};
(-)a/t/db_dependent/Koha/Biblio/ItemGroups.t (-2 / +8 lines)
Lines 36-42 t::lib::Mocks::mock_preference('EnableItemGroups', 1); Link Here
36
36
37
subtest 'add_item() and items() tests' => sub {
37
subtest 'add_item() and items() tests' => sub {
38
38
39
    plan tests => 8;
39
    plan tests => 10;
40
40
41
    $schema->storage->txn_begin;
41
    $schema->storage->txn_begin;
42
42
Lines 66-70 subtest 'add_item() and items() tests' => sub { Link Here
66
    is( scalar(@items), 1, 'Item group now has only one item');
66
    is( scalar(@items), 1, 'Item group now has only one item');
67
    is( $items[0]->id, $item_2->id, 'Item 2 is correct' );
67
    is( $items[0]->id, $item_2->id, 'Item 2 is correct' );
68
68
69
    # Remove last item
70
    $item_2->delete;
71
    @items = $item_group->items->as_list();
72
    is( scalar(@items), 0, "Item group now has no items");
73
    $item_group = Koha::Biblio::ItemGroups->find( $item_group->id );
74
    is( $item_group, undef, 'ItemGroup is deleted when last item is deleted' );
75
69
    $schema->storage->txn_rollback;
76
    $schema->storage->txn_rollback;
70
};
77
};
71
- 

Return to bug 24857