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

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

Return to bug 24680