From 06744823ef0f694fc959e67cd61c14e0e6477888 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 20 Jan 2025 17:03:52 -0300 Subject: [PATCH] Bug 38932: Make adding a credit return the Location header This patch makes the `POST /patrons/:patron_id/account/credits` endpoint return a valid `Location` header. Tests are added. Bonus: the debits counterpart already returned the header, but pointed to a non-existent endpoint (now added by bug 38931) and it gets tests added. To test: 1. Apply the regression tests patch 2. Run: $ ktd --shell k$ prove t/db_dependent/api/v1/patrons_accounts.t => FAIL: The behavior is not implemented for credits. 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: Tomas Cohen Arazi Signed-off-by: David Nind --- Koha/REST/V1/Patrons/Account.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Koha/REST/V1/Patrons/Account.pm b/Koha/REST/V1/Patrons/Account.pm index 338a4e9e13..35a8a1b053 100644 --- a/Koha/REST/V1/Patrons/Account.pm +++ b/Koha/REST/V1/Patrons/Account.pm @@ -168,6 +168,8 @@ sub add_credit { $credit->discard_changes; + $c->res->headers->location( $c->req->url->to_string . '/' . $credit->id ); + return $c->render( status => 201, openapi => $c->objects->to_api($credit), -- 2.39.5