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

(-)a/Koha/REST/V1/Holds.pm (-6 / +10 lines)
Lines 309-323 sub suspend { Link Here
309
        $hold->suspend_hold($date);
309
        $hold->suspend_hold($date);
310
        $hold->discard_changes;
310
        $hold->discard_changes;
311
        $c->res->headers->location( $c->req->url->to_string );
311
        $c->res->headers->location( $c->req->url->to_string );
312
        my $suspend_end_date;
313
        if ($hold->suspend_until) {
314
            $suspend_end_date = output_pref({
315
                dt         => dt_from_string( $hold->suspend_until ),
316
                dateformat => 'rfc3339',
317
                dateonly   => 1
318
                }
319
            );
320
        }
312
        return $c->render(
321
        return $c->render(
313
            status  => 201,
322
            status  => 201,
314
            openapi => {
323
            openapi => {
315
                end_date => output_pref(
324
                end_date => $suspend_end_date
316
                    {   dt         => dt_from_string( $hold->suspend_until ),
317
                        dateformat => 'rfc3339',
318
                        dateonly   => 1
319
                    }
320
                )
321
            }
325
            }
322
        );
326
        );
323
    }
327
    }
(-)a/t/db_dependent/api/v1/holds.t (-9 / +21 lines)
Lines 375-381 $schema->storage->txn_rollback; Link Here
375
375
376
subtest 'suspend and resume tests' => sub {
376
subtest 'suspend and resume tests' => sub {
377
377
378
    plan tests => 21;
378
    plan tests => 24;
379
379
380
    $schema->storage->txn_begin;
380
    $schema->storage->txn_begin;
381
381
Lines 403-416 subtest 'suspend and resume tests' => sub { Link Here
403
    $hold->discard_changes;    # refresh object
403
    $hold->discard_changes;    # refresh object
404
404
405
    ok( $hold->is_suspended, 'Hold is suspended' );
405
    ok( $hold->is_suspended, 'Hold is suspended' );
406
    $t->json_is('/end_date', undef, 'Hold suspension has no end date');
407
408
    my $end_date = output_pref({
409
      dt         => dt_from_string( undef ),
410
      dateformat => 'rfc3339',
411
      dateonly   => 1
412
    });
413
414
    $t->post_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" => json => { end_date => $end_date } );
415
416
    $hold->discard_changes;    # refresh object
417
418
    ok( $hold->is_suspended, 'Hold is suspended' );
406
    $t->json_is(
419
    $t->json_is(
407
        '/end_date',
420
      '/end_date',
408
        output_pref(
421
      output_pref({
409
            {   dt         => dt_from_string( $hold->suspend_until ),
422
        dt         => dt_from_string( $hold->suspend_until ),
410
                dateformat => 'rfc3339',
423
        dateformat => 'rfc3339',
411
                dateonly   => 1
424
        dateonly   => 1
412
            }
425
      }),
413
        )
426
      'Hold suspension has correct end date'
414
    );
427
    );
415
428
416
    $t->delete_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" )
429
    $t->delete_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" )
417
- 

Return to bug 24680