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

(-)a/t/db_dependent/api/v1/jobs.t (-2 / +53 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::NoWarnings;
20
use Test::NoWarnings;
21
use Test::More tests => 32;
21
use Test::More tests => 33;
22
use Test::Mojo;
22
use Test::Mojo;
23
23
24
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
Lines 140-142 my $job_current = $builder->build_object( Link Here
140
}
140
}
141
141
142
$schema->storage->txn_rollback;
142
$schema->storage->txn_rollback;
143
- 
143
144
subtest 'finished jobs' => sub {
145
146
    plan tests => 10;
147
148
    $schema->storage->txn_begin;
149
150
    my $password = 'thePassword123';
151
    my $patron   = $builder->build_object(
152
        {
153
            class => 'Koha::Patrons',
154
            value => { flags => 1 },    # superlibrarian
155
        }
156
    );
157
    $patron->set_password( { password => $password, skip_validation => 1 } );
158
    my $userid = $patron->userid;
159
160
    my $job = $builder->build_object(
161
        {
162
            class => 'Koha::BackgroundJobs',
163
            value => {
164
                status   => 'new',
165
                progress => 0,
166
                size     => 100,
167
                type     => 'batch_item_record_modification',
168
                queue    => 'default',
169
                data     =>
170
                    '{"regex_mod":null,"report":{"total_records":1,"modified_fields":1,"modified_itemnumbers":[1]},"new_values":{"itemnotes":"xxx"},"record_ids":["1"],"exclude_from_local_holds_priority":null}',
171
            }
172
        }
173
    );
174
175
    $t->get_ok( "//$userid:$password@/api/v1/jobs/" . $job->id )->status_is(200)->json_is( $job->to_api );
176
177
    $job->finish( { french => 'fries' } )->discard_changes;
178
179
    $t->get_ok( "//$userid:$password@/api/v1/jobs/" . $job->id )->status_is(200)->json_is( $job->to_api );
180
181
    $job->set(
182
        {
183
            ended_on => undef,
184
            data     => undef,
185
        }
186
    )->store();
187
188
    $job->finish()->discard_changes();
189
190
    $t->get_ok( "//$userid:$password@/api/v1/jobs/" . $job->id )->status_is(200)->json_is( $job->to_api )
191
        ->json_is( '/data' => undef );
192
193
    $schema->storage->txn_rollback;
194
};

Return to bug 39771