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

(-)a/Koha/Item.pm (+6 lines)
Lines 230-237 sub delete { Link Here
230
    # FIXME check the item has no current issues
230
    # FIXME check the item has no current issues
231
    # i.e. raise the appropriate exception
231
    # i.e. raise the appropriate exception
232
232
233
    # Get the item group so we can delete it later if it has no items left
234
    my $item_group = C4::Context->preference('EnableItemGroups') ? $self->item_group : undef;
235
233
    my $result = $self->SUPER::delete;
236
    my $result = $self->SUPER::delete;
234
237
238
    # Delete the item gorup if it has no items left
239
    $item_group->delete if ( $item_group && $item_group->items->count == 0 );
240
235
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
241
    my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX });
236
    $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
242
    $indexer->index_records( $self->biblionumber, "specialUpdate", "biblioserver" )
237
        unless $params->{skip_record_index};
243
        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