This patch changes expiration_date for end_date as voted when the RFC
was approved.
It also adds a test for the Location header being added correctly when
suspending a hold (SWAGGER3.4.1)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
my $hold_id = $c->validation->param('hold_id');
my $hold = Koha::Holds->find($hold_id);
my $body = $c->req->json;
my $hold_id = $c->validation->param('hold_id');
my $hold = Koha::Holds->find($hold_id);
my $body = $c->req->json;
- my $exp_date = ($body) ? $body->{expiration_date} : undef;
+ my $end_date = ($body) ? $body->{end_date} : undef;
unless ($hold) {
return $c->render( status => 404, openapi => { error => 'Hold not found.' } );
}
return try {
unless ($hold) {
return $c->render( status => 404, openapi => { error => 'Hold not found.' } );
}
return try {
- my $date = ($exp_date) ? dt_from_string( $exp_date, 'rfc3339' ) : undef;
+ my $date = ($end_date) ? dt_from_string( $end_date, 'rfc3339' ) : undef;
$hold->suspend_hold($date);
$hold->discard_changes;
$c->res->headers->location( $c->req->url->to_string );
return $c->render(
status => 201,
openapi => {
$hold->suspend_hold($date);
$hold->discard_changes;
$c->res->headers->location( $c->req->url->to_string );
return $c->render(
status => 201,
openapi => {
- expiration_date => output_pref(
+ end_date => output_pref(
{ dt => dt_from_string( $hold->suspend_until ),
dateformat => 'rfc3339',
dateonly => 1
{ dt => dt_from_string( $hold->suspend_until ),
dateformat => 'rfc3339',
dateonly => 1
"schema": {
"type": "object",
"properties": {
"schema": {
"type": "object",
"properties": {
"description": "Date the hold suspension expires",
"type": "string",
"format": "date"
"description": "Date the hold suspension expires",
"type": "string",
"format": "date"
subtest 'suspend and resume tests' => sub {
subtest 'suspend and resume tests' => sub {
$schema->storage->txn_begin;
$schema->storage->txn_begin;
ok( $hold->is_suspended, 'Hold is suspended' );
$t->json_is(
ok( $hold->is_suspended, 'Hold is suspended' );
$t->json_is(
output_pref(
{ dt => dt_from_string( $hold->suspend_until ),
dateformat => 'rfc3339',
output_pref(
{ dt => dt_from_string( $hold->suspend_until ),
dateformat => 'rfc3339',
"//$userid:$password@/api/v1/holds/"
. $hold->id
. "/suspension" => json => {
"//$userid:$password@/api/v1/holds/"
. $hold->id
. "/suspension" => json => {
output_pref( { dt => $date, dateformat => 'rfc3339', dateonly => 1 } )
}
)->status_is( 201, 'Hold suspension created' )
output_pref( { dt => $date, dateformat => 'rfc3339', dateonly => 1 } )
}
)->status_is( 201, 'Hold suspension created' )
- ->json_is( '/expiration_date',
- output_pref( { dt => $date, dateformat => 'rfc3339', dateonly => 1 } ) );
+ ->json_is( '/end_date',
+ output_pref( { dt => $date, dateformat => 'rfc3339', dateonly => 1 } ) )
+ ->header_is( Location => "/api/v1/holds/" . $hold->id . "/suspension", 'The Location header is set' );
$t->delete_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" )
->status_is( 204, "Correct status when deleting a resource" )
$t->delete_ok( "//$userid:$password@/api/v1/holds/" . $hold->id . "/suspension" )
->status_is( 204, "Correct status when deleting a resource" )