Bugzilla – Attachment 121305 Details for
Bug 28424
POST /patrons/:patron_id/account/credits return value wrong
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28424: Fix patron credits route (POST)
Bug-28424-Fix-patron-credits-route-POST.patch (text/plain), 1.91 KB, created by
David Nind
on 2021-05-23 21:05:22 UTC
(
hide
)
Description:
Bug 28424: Fix patron credits route (POST)
Filename:
MIME Type:
Creator:
David Nind
Created:
2021-05-23 21:05:22 UTC
Size:
1.91 KB
patch
obsolete
>From 8cd6ddd053d2f92363a90bfe9a60bf9c2b39dde5 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 21 May 2021 18:25:12 -0300 >Subject: [PATCH] Bug 28424: Fix patron credits route (POST) > >This patch makes the route follow the coding guidelines and thus: >- Return the generated object >- Use the status code 201 for the response > >To test: >1. Apply the tests patch >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/patrons_accounts.t >=> FAIL: Tests fail. The reponse body and status is incorrect >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! >5. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/REST/V1/Patrons/Account.pm | 7 ++++++- > api/v1/swagger/paths/patrons_account.json | 2 +- > 2 files changed, 7 insertions(+), 2 deletions(-) > >diff --git a/Koha/REST/V1/Patrons/Account.pm b/Koha/REST/V1/Patrons/Account.pm >index c75f91a1f7..1bf64aa58c 100644 >--- a/Koha/REST/V1/Patrons/Account.pm >+++ b/Koha/REST/V1/Patrons/Account.pm >@@ -142,7 +142,12 @@ sub add_credit { > $credit->apply({ debits => [ $outstanding_debits->as_list ], offset_type => 'payment' }); > } > >- return $c->render( status => 200, openapi => { account_line_id => $credit->id } ); >+ $credit->discard_changes; >+ >+ return $c->render( >+ status => 201, >+ openapi => $credit->to_api >+ ); > } > catch { > $c->unhandled_exception($_); >diff --git a/api/v1/swagger/paths/patrons_account.json b/api/v1/swagger/paths/patrons_account.json >index 428999fe00..9e118d9ade 100644 >--- a/api/v1/swagger/paths/patrons_account.json >+++ b/api/v1/swagger/paths/patrons_account.json >@@ -85,7 +85,7 @@ > "application/json" > ], > "responses": { >- "200": { >+ "201": { > "description": "Credit added", > "schema": { > "type": "object" >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28424
:
121292
|
121293
|
121294
|
121295
|
121304
| 121305 |
121306
|
121307