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

(-)a/Koha/Hold.pm (-1 / +5 lines)
Lines 607-613 sub fill { Link Here
607
                }
607
                }
608
            );
608
            );
609
609
610
            $self->_move_to_old;
610
            my $old_me = $self->_move_to_old;
611
            # anonymize if required
612
            $old_me->anonymize
613
                if $patron->privacy == 2;
614
611
            $self->SUPER::delete(); # Do not add a DELETE log
615
            $self->SUPER::delete(); # Do not add a DELETE log
612
616
613
            # now fix the priority on the others....
617
            # now fix the priority on the others....
(-)a/t/db_dependent/Koha/Hold.t (-2 / +62 lines)
Lines 38-44 my $builder = t::lib::TestBuilder->new; Link Here
38
38
39
subtest 'fill() tests' => sub {
39
subtest 'fill() tests' => sub {
40
40
41
    plan tests => 11;
41
    plan tests => 12;
42
42
43
    $schema->storage->txn_begin;
43
    $schema->storage->txn_begin;
44
44
Lines 164-169 subtest 'fill() tests' => sub { Link Here
164
164
165
    is( $logs->count, 0, 'HoldsLog disabled, no logs added' );
165
    is( $logs->count, 0, 'HoldsLog disabled, no logs added' );
166
166
167
    subtest 'anonymization behavior tests' => sub {
168
169
        plan tests => 4;
170
171
        # reduce the tests noise
172
        t::lib::Mocks::mock_preference( 'HoldsLog',    0 );
173
        t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' );
174
175
        # 0 == keep forever
176
        $patron->privacy(0)->store;
177
        my $hold = $builder->build_object(
178
            {
179
                class => 'Koha::Holds',
180
                value => { borrowernumber => $patron->id, status => undef }
181
            }
182
        );
183
        $hold->fill();
184
        is( Koha::Old::Holds->find( $hold->id )->borrowernumber,
185
            $patron->borrowernumber, 'Patron link is kept' );
186
187
        # 1 == "default", meaning it is not protected from removal
188
        $patron->privacy(1)->store;
189
        $hold = $builder->build_object(
190
            {
191
                class => 'Koha::Holds',
192
                value => { borrowernumber => $patron->id, status => undef }
193
            }
194
        );
195
        $hold->fill();
196
        is( Koha::Old::Holds->find( $hold->id )->borrowernumber,
197
            $patron->borrowernumber, 'Patron link is kept' );
198
199
        # 2 == delete immediately
200
        $patron->privacy(2)->store;
201
        $hold = $builder->build_object(
202
            {
203
                class => 'Koha::Holds',
204
                value => { borrowernumber => $patron->id, status => undef }
205
            }
206
        );
207
        $hold->fill();
208
        is( Koha::Old::Holds->find( $hold->id )->borrowernumber,
209
            undef, 'Patron link is deleted immediately' );
210
211
        my $anonymous_patron = $builder->build_object({ class => 'Koha::Patrons' });
212
        t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous_patron->id );
213
214
        $hold = $builder->build_object(
215
            {
216
                class => 'Koha::Holds',
217
                value => { borrowernumber => $patron->id, status => undef }
218
            }
219
        );
220
        $hold->cancel();
221
        is(
222
            Koha::Old::Holds->find( $hold->id )->borrowernumber,
223
            $anonymous_patron->id,
224
            'Patron link is set to the configured anonymous patron immediately'
225
        );
226
    };
227
167
    $schema->storage->txn_rollback;
228
    $schema->storage->txn_rollback;
168
};
229
};
169
230
170
- 

Return to bug 29525