|
Lines 409-414
subtest 'update() tests' => sub {
Link Here
|
| 409 |
delete $newpatron->{patron_id}; |
409 |
delete $newpatron->{patron_id}; |
| 410 |
delete $newpatron->{restricted}; |
410 |
delete $newpatron->{restricted}; |
| 411 |
delete $newpatron->{anonymized}; |
411 |
delete $newpatron->{anonymized}; |
|
|
412 |
# delete field set by a trigger because it is fragile for comparisons |
| 413 |
delete $newpatron->{updated_on}; |
| 412 |
|
414 |
|
| 413 |
$t->put_ok("//$userid:$password@/api/v1/patrons/-1" => json => $newpatron) |
415 |
$t->put_ok("//$userid:$password@/api/v1/patrons/-1" => json => $newpatron) |
| 414 |
->status_is(404) |
416 |
->status_is(404) |
|
Lines 475-487
subtest 'update() tests' => sub {
Link Here
|
| 475 |
$newpatron->{ surname } = "user" . $patron_1->id.$patron_2->id; |
477 |
$newpatron->{ surname } = "user" . $patron_1->id.$patron_2->id; |
| 476 |
|
478 |
|
| 477 |
my $result = $t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) |
479 |
my $result = $t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) |
| 478 |
->status_is(200, 'Patron updated successfully'); |
480 |
->status_is(200, 'Patron updated successfully')->tx->res->json; |
| 479 |
|
481 |
|
| 480 |
# Put back the RO attributes |
482 |
# Test the updated attributes are returned correctly |
| 481 |
$newpatron->{patron_id} = $unauthorized_patron->to_api->{patron_id}; |
483 |
my $matches = 0; |
| 482 |
$newpatron->{restricted} = $unauthorized_patron->to_api->{restricted}; |
484 |
my @attributes = keys %{$newpatron}; |
| 483 |
$newpatron->{anonymized} = $unauthorized_patron->to_api->{anonymized}; |
485 |
foreach my $attribute (@attributes) { |
| 484 |
is_deeply($result->tx->res->json, $newpatron, 'Returned patron from update matches expected'); |
486 |
if ( exists $result->{$attribute} |
|
|
487 |
and $result->{$attribute} eq $newpatron->{$attribute} ) { |
| 488 |
$matches++; |
| 489 |
} |
| 490 |
else { |
| 491 |
warn $result->{$attribute} . " vs " . $newpatron->{$attribute} . " ($attribute)"; |
| 492 |
} |
| 493 |
|
| 494 |
} |
| 495 |
|
| 496 |
is( $matches, scalar @attributes, 'Returned patron from update matches expected' ); |
| 485 |
|
497 |
|
| 486 |
is(Koha::Patrons->find( $patron_2->id )->cardnumber, |
498 |
is(Koha::Patrons->find( $patron_2->id )->cardnumber, |
| 487 |
$newpatron->{ cardnumber }, 'Patron is really updated!'); |
499 |
$newpatron->{ cardnumber }, 'Patron is really updated!'); |
| 488 |
- |
|
|