Bugzilla – Attachment 59697 Details for
Bug 17932
Koha::Object should provide a TO_JSON method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17932: (followup) Fix /patrons endpoint
Bug-17932-followup-Fix-patrons-endpoint.patch (text/plain), 3.30 KB, created by
Nick Clemens (kidclamp)
on 2017-01-31 18:57:18 UTC
(
hide
)
Description:
Bug 17932: (followup) Fix /patrons endpoint
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-01-31 18:57:18 UTC
Size:
3.30 KB
patch
obsolete
>From 89a7927e6311bced5dc4fe3b264228975139e2d1 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 23 Jan 2017 09:47:54 -0300 >Subject: [PATCH] Bug 17932: (followup) Fix /patrons endpoint > >Bug 17927 introduced data type fixes on the /patrons endpoint (integer >and boolean types got fixed). This led to the /patrons endpoint not to >work because the underlying code didn't provide the right data. > >With the introduction of TO_JSON on Koha::Object(s) we now have a way to >output the proper data types. > >This patch does so by: >- Adding is_boolean => 1 to the relevant columns on the Borrower.pm > schema file. >- Tweaking the controller class for the /patrons endpoint so it doesn't > use the $object(s)->unblessed call but just let the Mojo::JSON library > pick out TO_JSON implementation instead on rendering the output. >- It adds a new test for booleans. > >To test: >- Have 17927 applied >- Run: > $ prove t/db_dependent/api/v1/patrons.t >=> FAIL: Tests fail [1] >- Apply this patches >- Run: > $ prove t/db_dependent/api/v1/patrons.t >=> SUCCESS: Tests pass! >- Sign off! :-D > >[1] It is self explanatory to just try the API using any of the >available tools (I use HttpRequester on Firefox) > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/REST/V1/Patron.pm | 4 ++-- > Koha/Schema/Result/Borrower.pm | 5 +++++ > t/db_dependent/api/v1/patrons.t | 8 +++++--- > 3 files changed, 12 insertions(+), 5 deletions(-) > >diff --git a/Koha/REST/V1/Patron.pm b/Koha/REST/V1/Patron.pm >index b97a154..477980e 100644 >--- a/Koha/REST/V1/Patron.pm >+++ b/Koha/REST/V1/Patron.pm >@@ -28,7 +28,7 @@ sub list { > > my $patrons = Koha::Patrons->search; > >- $c->$cb($patrons->unblessed, 200); >+ $c->$cb($patrons, 200); > } > > sub get { >@@ -41,7 +41,7 @@ sub get { > return $c->$cb({error => "Patron not found"}, 404); > } > >- return $c->$cb($patron->unblessed, 200); >+ return $c->$cb($patron, 200); > } > > 1; >diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm >index 1fe3988..ac414b4 100644 >--- a/Koha/Schema/Result/Borrower.pm >+++ b/Koha/Schema/Result/Borrower.pm >@@ -1343,6 +1343,11 @@ __PACKAGE__->belongs_to( > { borrowernumber => "guarantorid" }, > ); > >+__PACKAGE__->add_columns( >+ '+lost' => { is_boolean => 1 }, >+ '+gonenoaddress' => { is_boolean => 1 } >+); >+ > sub koha_objects_class { > 'Koha::Patrons'; > } >diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t >index f4b9410..6b3f51f 100644 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 20; >+use Test::More tests => 21; > use Test::Mojo; > use t::lib::TestBuilder; > >@@ -52,7 +52,8 @@ my $borrower = $builder->build({ > branchcode => $branchcode, > categorycode => $categorycode, > flags => 0, >- guarantorid => $guarantor->{borrowernumber}, >+ lost => 1, >+ guarantorid => $guarantor->{borrowernumber}, > } > }); > >@@ -127,6 +128,7 @@ $tx->req->cookies({name => 'CGISESSID', value => $session->id}); > $t->request_ok($tx) > ->status_is(200) > ->json_is('/borrowernumber' => $borrower->{ borrowernumber }) >- ->json_is('/surname' => $borrower->{ surname }); >+ ->json_is('/surname' => $borrower->{ surname }) >+ ->json_is('/lost' => 1 ); > > $dbh->rollback; >-- >2.1.4
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 17932
:
59431
|
59432
|
59498
|
59499
|
59500
|
59501
|
59696
|
59697
|
59698
|
59699
|
60072
|
60073
|
60074
|
60075