View | Details | Raw Unified | Return to bug 16330
Collapse All | Expand All

(-)a/Koha/REST/V1/Patrons.pm (-1 / +4 lines)
Lines 154-160 sub update { Link Here
154
154
155
        $patron->set( _to_model($body) )->_validate;
155
        $patron->set( _to_model($body) )->_validate;
156
156
157
        # TODO: Use ModMember until it has been moved to Koha-namespace
157
        ## TODO: Use ModMember until it has been moved to Koha-namespace
158
        # Add borrowernumber to $body, as required by ModMember
159
        $body->{borrowernumber} = $patron->borrowernumber;
160
158
        if ( ModMember(%$body) ) {
161
        if ( ModMember(%$body) ) {
159
            return $c->render( status => 200, openapi => $patron );
162
            return $c->render( status => 200, openapi => $patron );
160
        }
163
        }
(-)a/t/db_dependent/api/v1/patrons.t (-4 / +4 lines)
Lines 231-236 subtest 'update() tests' => sub { Link Here
231
        my $patron_1  = Koha::Patrons->find($borrowernumber);
231
        my $patron_1  = Koha::Patrons->find($borrowernumber);
232
        my $patron_2  = Koha::Patrons->find($borrowernumber2);
232
        my $patron_2  = Koha::Patrons->find($borrowernumber2);
233
        my $newpatron = $patron_2->TO_JSON;
233
        my $newpatron = $patron_2->TO_JSON;
234
        # borrowernumber should not be passed in the request body for PUT
235
        delete $newpatron->{borrowernumber};
234
236
235
        my $tx = $t->ua->build_tx(PUT => "/api/v1/patrons/-1" => json => $newpatron );
237
        my $tx = $t->ua->build_tx(PUT => "/api/v1/patrons/-1" => json => $newpatron );
236
        $tx->req->cookies({name => 'CGISESSID', value => $sessionid});
238
        $tx->req->cookies({name => 'CGISESSID', value => $sessionid});
Lines 282-294 subtest 'update() tests' => sub { Link Here
282
        $newpatron->{ userid } = "user".$borrowernumber.$borrowernumber2;
284
        $newpatron->{ userid } = "user".$borrowernumber.$borrowernumber2;
283
        $newpatron->{ surname } = "user".$borrowernumber.$borrowernumber2;
285
        $newpatron->{ surname } = "user".$borrowernumber.$borrowernumber2;
284
286
285
        $tx = $t->ua->build_tx(PUT => "/api/v1/patrons/" .
287
        $tx = $t->ua->build_tx(PUT => "/api/v1/patrons/" . $patron_2->id => json => $newpatron);
286
                    $newpatron->{borrowernumber} => json => $newpatron);
287
        $tx->req->cookies({name => 'CGISESSID', value => $sessionid});
288
        $tx->req->cookies({name => 'CGISESSID', value => $sessionid});
288
        $t->request_ok($tx)
289
        $t->request_ok($tx)
289
          ->status_is(200, 'Patron updated successfully')
290
          ->status_is(200, 'Patron updated successfully')
290
          ->json_has($newpatron);
291
          ->json_has($newpatron);
291
        is(Koha::Patrons->find($newpatron->{borrowernumber})->cardnumber,
292
        is(Koha::Patrons->find( $patron_2->id )->cardnumber,
292
           $newpatron->{ cardnumber }, 'Patron is really updated!');
293
           $newpatron->{ cardnumber }, 'Patron is really updated!');
293
    };
294
    };
294
295
295
- 

Return to bug 16330