Bugzilla – Attachment 69768 Details for
Bug 16330
Add routes to add, update and delete patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16330: (QA follow-up) ModMember requires borrowernumber
Bug-16330-QA-follow-up-ModMember-requires-borrower.patch (text/plain), 2.96 KB, created by
Benjamin Rokseth
on 2017-12-13 08:31:18 UTC
(
hide
)
Description:
Bug 16330: (QA follow-up) ModMember requires borrowernumber
Filename:
MIME Type:
Creator:
Benjamin Rokseth
Created:
2017-12-13 08:31:18 UTC
Size:
2.96 KB
patch
obsolete
>From 180338f62fb79ea2c8e8ea57ca2aa36c94604105 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 12 Dec 2017 18:53:45 -0300 >Subject: [PATCH] Bug 16330: (QA follow-up) ModMember requires borrowernumber > >This patch fixes the tests so they highlight the fact that: >- PUT only worked on the tests because borrowernumber was passed on them >- ModMember expects borrowernumber on the hash it gets passed. > >It also fixes the issue. > >To test: >- Apply this patch >- Run: > $ kshell > k$ prove t/db_dependent/api/v1/patrons.t >=> SUCCESS: Tests pass > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no> >--- > Koha/REST/V1/Patrons.pm | 5 ++++- > t/db_dependent/api/v1/patrons.t | 7 ++++--- > 2 files changed, 8 insertions(+), 4 deletions(-) > >diff --git a/Koha/REST/V1/Patrons.pm b/Koha/REST/V1/Patrons.pm >index 357c099..7868e8d 100644 >--- a/Koha/REST/V1/Patrons.pm >+++ b/Koha/REST/V1/Patrons.pm >@@ -154,7 +154,10 @@ sub update { > > $patron->set( _to_model($body) )->_validate; > >- # TODO: Use ModMember until it has been moved to Koha-namespace >+ ## TODO: Use ModMember until it has been moved to Koha-namespace >+ # Add borrowernumber to $body, as required by ModMember >+ $body->{borrowernumber} = $patron->borrowernumber; >+ > if ( ModMember(%$body) ) { > return $c->render( status => 200, openapi => $patron ); > } >diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t >index e850259..b52066d 100644 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -231,6 +231,8 @@ subtest 'update() tests' => sub { > my $patron_1 = Koha::Patrons->find($borrowernumber); > my $patron_2 = Koha::Patrons->find($borrowernumber2); > my $newpatron = $patron_2->TO_JSON; >+ # borrowernumber should not be passed in the request body for PUT >+ delete $newpatron->{borrowernumber}; > > my $tx = $t->ua->build_tx(PUT => "/api/v1/patrons/-1" => json => $newpatron ); > $tx->req->cookies({name => 'CGISESSID', value => $sessionid}); >@@ -282,13 +284,12 @@ subtest 'update() tests' => sub { > $newpatron->{ userid } = "user".$borrowernumber.$borrowernumber2; > $newpatron->{ surname } = "user".$borrowernumber.$borrowernumber2; > >- $tx = $t->ua->build_tx(PUT => "/api/v1/patrons/" . >- $newpatron->{borrowernumber} => json => $newpatron); >+ $tx = $t->ua->build_tx(PUT => "/api/v1/patrons/" . $patron_2->id => json => $newpatron); > $tx->req->cookies({name => 'CGISESSID', value => $sessionid}); > $t->request_ok($tx) > ->status_is(200, 'Patron updated successfully') > ->json_has($newpatron); >- is(Koha::Patrons->find($newpatron->{borrowernumber})->cardnumber, >+ is(Koha::Patrons->find( $patron_2->id )->cardnumber, > $newpatron->{ cardnumber }, 'Patron is really updated!'); > }; > >-- >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 16330
:
50803
|
50889
|
51066
|
51131
|
51132
|
53216
|
53217
|
53820
|
54942
|
55147
|
56666
|
56667
|
56668
|
63646
|
63647
|
63649
|
63650
|
69546
|
69547
|
69548
|
69549
|
69550
|
69551
|
69752
|
69762
|
69763
|
69764
|
69765
|
69766
|
69767
|
69768
|
69787
|
70034
|
70035
|
70036
|
70037
|
70038
|
71667
|
71668
|
71669
|
71670
|
71671
|
71920
|
71921
|
71922
|
71923
|
71924
|
71925
|
71933
|
71934
|
71935
|
71936
|
71937
|
71938
|
73434