|
Lines 302-308
subtest 'add() tests' => sub {
Link Here
|
| 302 |
$schema->storage->txn_rollback; |
302 |
$schema->storage->txn_rollback; |
| 303 |
|
303 |
|
| 304 |
subtest 'librarian access tests' => sub { |
304 |
subtest 'librarian access tests' => sub { |
| 305 |
plan tests => 25; |
305 |
plan tests => 24; |
| 306 |
|
306 |
|
| 307 |
$schema->storage->txn_begin; |
307 |
$schema->storage->txn_begin; |
| 308 |
|
308 |
|
|
Lines 364-374
subtest 'add() tests' => sub {
Link Here
|
| 364 |
|
364 |
|
| 365 |
$newpatron->{library_id} = $deleted_library_id; |
365 |
$newpatron->{library_id} = $deleted_library_id; |
| 366 |
|
366 |
|
| 367 |
warning_like { |
367 |
$t->post_ok("//$userid:$password@/api/v1/patrons" => json => $newpatron) |
| 368 |
$t->post_ok("//$userid:$password@/api/v1/patrons" => json => $newpatron) |
368 |
->status_is(400) |
| 369 |
->status_is(409) |
369 |
->json_is('/error' => "Problem with ". $newpatron->{userid} ); |
| 370 |
->json_is('/error' => "Duplicate ID"); } |
|
|
| 371 |
qr/DBD::mysql::st execute failed: Duplicate entry/; |
| 372 |
|
370 |
|
| 373 |
$newpatron->{library_id} = $patron->branchcode; |
371 |
$newpatron->{library_id} = $patron->branchcode; |
| 374 |
|
372 |
|
|
Lines 418-423
subtest 'add() tests' => sub {
Link Here
|
| 418 |
->json_is( '/date_of_birth' => $newpatron->{ date_of_birth }, 'Date field set (Bug 28585)' ) |
416 |
->json_is( '/date_of_birth' => $newpatron->{ date_of_birth }, 'Date field set (Bug 28585)' ) |
| 419 |
->json_is( '/last_seen' => $newpatron->{ last_seen }, 'Date-time field set (Bug 28585)' ); |
417 |
->json_is( '/last_seen' => $newpatron->{ last_seen }, 'Date-time field set (Bug 28585)' ); |
| 420 |
|
418 |
|
|
|
419 |
$newpatron->{userid} = undef; # force regeneration |
| 421 |
warning_like { |
420 |
warning_like { |
| 422 |
$t->post_ok("//$userid:$password@/api/v1/patrons" => json => $newpatron) |
421 |
$t->post_ok("//$userid:$password@/api/v1/patrons" => json => $newpatron) |
| 423 |
->status_is(409) |
422 |
->status_is(409) |
|
Lines 592-598
subtest 'update() tests' => sub {
Link Here
|
| 592 |
$schema->storage->txn_rollback; |
591 |
$schema->storage->txn_rollback; |
| 593 |
|
592 |
|
| 594 |
subtest 'librarian access tests' => sub { |
593 |
subtest 'librarian access tests' => sub { |
| 595 |
plan tests => 45; |
594 |
plan tests => 43; |
| 596 |
|
595 |
|
| 597 |
$schema->storage->txn_begin; |
596 |
$schema->storage->txn_begin; |
| 598 |
|
597 |
|
|
Lines 677-688
subtest 'update() tests' => sub {
Link Here
|
| 677 |
$newpatron->{cardnumber} = $patron_1->cardnumber; |
676 |
$newpatron->{cardnumber} = $patron_1->cardnumber; |
| 678 |
$newpatron->{userid} = $patron_1->userid; |
677 |
$newpatron->{userid} = $patron_1->userid; |
| 679 |
|
678 |
|
| 680 |
warning_like { |
679 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) |
| 681 |
$t->put_ok( "//$userid:$password@/api/v1/patrons/" . $patron_2->borrowernumber => json => $newpatron ) |
680 |
->status_is(400) |
| 682 |
->status_is(409) |
681 |
->json_has( '/error', "Problem with userid ". $patron_1->userid ); |
| 683 |
->json_has( '/error', "Fails when trying to update to an existing cardnumber or userid") |
|
|
| 684 |
->json_like( '/conflict' => qr/(borrowers\.)?cardnumber/ ); } |
| 685 |
qr/DBD::mysql::st execute failed: Duplicate entry '(.*?)' for key '(borrowers\.)?cardnumber'/; |
| 686 |
|
682 |
|
| 687 |
$newpatron->{ cardnumber } = $patron_1->id . $patron_2->id; |
683 |
$newpatron->{ cardnumber } = $patron_1->id . $patron_2->id; |
| 688 |
$newpatron->{ userid } = "user" . $patron_1->id.$patron_2->id; |
684 |
$newpatron->{ userid } = "user" . $patron_1->id.$patron_2->id; |
| 689 |
- |
|
|