|
Lines 462-467
subtest 'update() tests' => sub {
Link Here
|
| 462 |
delete $newpatron->{patron_id}; |
462 |
delete $newpatron->{patron_id}; |
| 463 |
delete $newpatron->{restricted}; |
463 |
delete $newpatron->{restricted}; |
| 464 |
delete $newpatron->{anonymized}; |
464 |
delete $newpatron->{anonymized}; |
|
|
465 |
# delete field set by a trigger because it is fragile for comparisons |
| 466 |
delete $newpatron->{updated_on}; |
| 465 |
|
467 |
|
| 466 |
$t->put_ok("//$userid:$password@/api/v1/patrons/-1" => json => $newpatron) |
468 |
$t->put_ok("//$userid:$password@/api/v1/patrons/-1" => json => $newpatron) |
| 467 |
->status_is(404) |
469 |
->status_is(404) |
|
Lines 528-540
subtest 'update() tests' => sub {
Link Here
|
| 528 |
$newpatron->{ surname } = "user" . $patron_1->id.$patron_2->id; |
530 |
$newpatron->{ surname } = "user" . $patron_1->id.$patron_2->id; |
| 529 |
|
531 |
|
| 530 |
my $result = $t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) |
532 |
my $result = $t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) |
| 531 |
->status_is(200, 'Patron updated successfully'); |
533 |
->status_is(200, 'Patron updated successfully')->tx->res->json; |
| 532 |
|
534 |
|
| 533 |
# Put back the RO attributes |
535 |
# Test the updated attributes are returned correctly |
| 534 |
$newpatron->{patron_id} = $unauthorized_patron->to_api->{patron_id}; |
536 |
my $matches = 0; |
| 535 |
$newpatron->{restricted} = $unauthorized_patron->to_api->{restricted}; |
537 |
my @attributes = keys %{$newpatron}; |
| 536 |
$newpatron->{anonymized} = $unauthorized_patron->to_api->{anonymized}; |
538 |
foreach my $attribute (@attributes) { |
| 537 |
is_deeply($result->tx->res->json, $newpatron, 'Returned patron from update matches expected'); |
539 |
if ( exists $result->{$attribute} |
|
|
540 |
and $result->{$attribute} eq $newpatron->{$attribute} ) { |
| 541 |
$matches++; |
| 542 |
} |
| 543 |
else { |
| 544 |
warn $result->{$attribute} . " vs " . $newpatron->{$attribute} . " ($attribute)"; |
| 545 |
} |
| 546 |
|
| 547 |
} |
| 548 |
|
| 549 |
is( $matches, scalar @attributes, 'Returned patron from update matches expected' ); |
| 538 |
|
550 |
|
| 539 |
is(Koha::Patrons->find( $patron_2->id )->cardnumber, |
551 |
is(Koha::Patrons->find( $patron_2->id )->cardnumber, |
| 540 |
$newpatron->{ cardnumber }, 'Patron is really updated!'); |
552 |
$newpatron->{ cardnumber }, 'Patron is really updated!'); |
| 541 |
- |
|
|