Bug 16330: (QA follow-up) ModMember requires borrowernumber
Works perfectly. Well done everyone! Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Benjamin Rokseth <benjamin.rokseth@kul.oslo.kommune.no> Signed-off-by: Dilan Johnpullé <dilan@calyx.net.au> Signed-off-by: Josef Moravec <josef.moravec@gmail.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
6c3a273af9
commit
e36dc18376
2 changed files with 8 additions and 4 deletions
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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!');
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue