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

(-)a/Koha/Virtualshelves.pm (-2 / +2 lines)
Lines 48-54 sub disown_or_delete { Link Here
48
    my $list_pref = C4::Context->preference('ListOwnershipUponPatronDeletion');
48
    my $list_pref = C4::Context->preference('ListOwnershipUponPatronDeletion');
49
    $self->_resultset->result_source->schema->txn_do(
49
    $self->_resultset->result_source->schema->txn_do(
50
        sub {
50
        sub {
51
            if ( $list_pref ne 'delete' ) { # transfer or transfer_public
51
            if ( $list_pref ne 'delete' ) {    # transfer or transfer_public
52
                my $new_owner;
52
                my $new_owner;
53
53
54
                $new_owner = C4::Context->preference('ListOwnerDesignated')
54
                $new_owner = C4::Context->preference('ListOwnerDesignated')
Lines 64-70 sub disown_or_delete { Link Here
64
                        $list->transfer_ownership($new_owner);
64
                        $list->transfer_ownership($new_owner);
65
                    } elsif ( $new_owner && $list->is_shared && $list_pref eq 'transfer' ) {
65
                    } elsif ( $new_owner && $list->is_shared && $list_pref eq 'transfer' ) {
66
                        $list->transfer_ownership($new_owner);
66
                        $list->transfer_ownership($new_owner);
67
                    } else { # private list, or shared list with transfer_public
67
                    } else {    # private list, or shared list with transfer_public
68
                        $list->delete;
68
                        $list->delete;
69
                    }
69
                    }
70
                }
70
                }
(-)a/installer/data/mysql/atomicupdate/bug_39145.pl (-2 / +4 lines)
Lines 8-16 return { Link Here
8
        my ($args) = @_;
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
10
11
        $dbh->do(q{
11
        $dbh->do(
12
            q{
12
            UPDATE systempreferences SET options='delete|transfer|transfer_public' WHERE variable = 'ListOwnershipUponPatronDeletion'
13
            UPDATE systempreferences SET options='delete|transfer|transfer_public' WHERE variable = 'ListOwnershipUponPatronDeletion'
13
        });
14
        }
15
        );
14
        say $out "Updated system preference 'ListOwnershipUponPatronDeletion'";
16
        say $out "Updated system preference 'ListOwnershipUponPatronDeletion'";
15
    },
17
    },
16
};
18
};
(-)a/t/db_dependent/Koha/Virtualshelves.t (-7 / +5 lines)
Lines 175-183 subtest 'disown_or_delete() tests' => sub { Link Here
175
    subtest 'ListOwnershipUponPatronDeletion set to transfer_public' => sub {
175
    subtest 'ListOwnershipUponPatronDeletion set to transfer_public' => sub {
176
        plan tests => 2;
176
        plan tests => 2;
177
        $schema->storage->txn_begin;
177
        $schema->storage->txn_begin;
178
        my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } );
178
        my $patron_1    = $builder->build_object( { class => 'Koha::Patrons' } );
179
        my $patron_2 = $builder->build_object( { class => 'Koha::Patrons' } );
179
        my $patron_2    = $builder->build_object( { class => 'Koha::Patrons' } );
180
        my $patron_3 = $builder->build_object( { class => 'Koha::Patrons' } );
180
        my $patron_3    = $builder->build_object( { class => 'Koha::Patrons' } );
181
        my $public_list = $builder->build_object(
181
        my $public_list = $builder->build_object(
182
            {
182
            {
183
                class => "Koha::Virtualshelves",
183
                class => "Koha::Virtualshelves",
Lines 201-213 subtest 'disown_or_delete() tests' => sub { Link Here
201
        t::lib::Mocks::mock_preference( 'ListOwnershipUponPatronDeletion', 'transfer_public' );
201
        t::lib::Mocks::mock_preference( 'ListOwnershipUponPatronDeletion', 'transfer_public' );
202
        t::lib::Mocks::mock_preference( 'ListOwnerDesignated',             $patron_3->id );
202
        t::lib::Mocks::mock_preference( 'ListOwnerDesignated',             $patron_3->id );
203
203
204
        my $rs = Koha::Virtualshelves->search(
204
        my $rs = Koha::Virtualshelves->search( { shelfnumber => [ $public_list->id, $private_list_shared->id ] } );
205
            { shelfnumber => [ $public_list->id, $private_list_shared->id ] } );
206
205
207
        my $result = $rs->disown_or_delete;
206
        my $result = $rs->disown_or_delete;
208
        $rs->reset;
207
        $rs->reset;
209
208
210
        is( $rs->count, 1, 'Only public list should be transferred' );
209
        is( $rs->count,    1,                'Only public list should be transferred' );
211
        is( $rs->next->id, $public_list->id, 'Check id too' );
210
        is( $rs->next->id, $public_list->id, 'Check id too' );
212
211
213
        $schema->storage->txn_rollback;
212
        $schema->storage->txn_rollback;
214
- 

Return to bug 39145