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

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

Return to bug 29525