AddRenewal($borrowernumber, $itemnumber, $checkout->branchcode);
$checkout = Koha::Checkouts->find($checkout_id);
+ $c->res->headers->location( $c->req->url->to_string );
return $c->render(
- status => 200,
+ status => 201,
openapi => _to_api( $checkout->TO_JSON )
);
}
}],
"produces": ["application/json"],
"responses": {
- "200": {
+ "201": {
"description": "Updated borrower's checkout",
"schema": { "$ref": "../definitions.json#/checkout" }
},
use Modern::Perl;
-use Test::More tests => 51;
+use Test::More tests => 53;
use Test::MockModule;
use Test::Mojo;
use t::lib::Mocks;
my $expected_datedue = DateTime->now->add(days => 14)->set(hour => 23, minute => 59, second => 0);
$t->post_ok ( "//$userid:$password@/api/v1/checkouts/" . $issue1->issue_id . "/renewal" )
- ->status_is(200)
- ->json_is('/due_date' => output_pref( { dateformat => "rfc3339", dt => $expected_datedue }) );
+ ->status_is(201)
+ ->json_is('/due_date' => output_pref( { dateformat => "rfc3339", dt => $expected_datedue }) )
+ ->header_is(Location => "/api/v1/checkouts/" . $issue1->issue_id . "/renewal");
$t->post_ok( "//$unauth_userid:$unauth_password@/api/v1/checkouts/" . $issue3->issue_id . "/renewal" )
->status_is(403)
});
$t->post_ok( "//$userid:$password@/api/v1/checkouts/" . $issue2->issue_id . "/renewal" )
- ->status_is(200)
- ->json_is('/due_date' => output_pref({ dateformat => "rfc3339", dt => $expected_datedue}) );
+ ->status_is(201)
+ ->json_is('/due_date' => output_pref({ dateformat => "rfc3339", dt => $expected_datedue}) )
+ ->header_is(Location => "/api/v1/checkouts/" . $issue2->issue_id . "/renewal");
+
$t->post_ok( "//$userid:$password@/api/v1/checkouts/" . $issue1->issue_id . "/renewal" )
->status_is(403)