Lines 408-410
subtest 'add checkout' => sub {
Link Here
|
408 |
|
408 |
|
409 |
$schema->storage->txn_rollback; |
409 |
$schema->storage->txn_rollback; |
410 |
}; |
410 |
}; |
411 |
- |
411 |
|
|
|
412 |
subtest 'delete checkout' => sub { |
413 |
|
414 |
plan tests => 4; |
415 |
|
416 |
$schema->storage->txn_begin; |
417 |
my $librarian = $builder->build_object( |
418 |
{ |
419 |
class => 'Koha::Patrons', |
420 |
value => { flags => 2 } |
421 |
} |
422 |
); |
423 |
my $password = 'thePassword123'; |
424 |
$librarian->set_password( { password => $password, skip_validation => 1 } ); |
425 |
my $userid = $librarian->userid; |
426 |
|
427 |
my $patron = $builder->build_object( |
428 |
{ |
429 |
class => 'Koha::Patrons', |
430 |
value => { flags => 0 } |
431 |
} |
432 |
); |
433 |
my $unauth_password = 'thePassword000'; |
434 |
$patron->set_password( |
435 |
{ password => $unauth_password, skip_validattion => 1 } ); |
436 |
my $unauth_userid = $patron->userid; |
437 |
|
438 |
my $branch = $builder->build_sample_branch; |
439 |
my $library_id = $branch->id; |
440 |
my $item1 = $builder->build_sample_item; |
441 |
my $item1_id = $item1->id; |
442 |
|
443 |
|
444 |
$t->delete_ok( |
445 |
"//$unauth_userid:$unauth_password@/api/v1/checkouts" => json => |
446 |
{ item_id => $item1_id, library_id => $library_id } )->status_is(403) |
447 |
->json_is( |
448 |
{ |
449 |
error => "checkin not allowed", |
450 |
required_permissions => |
451 |
{ circulate => "circulate_remaining_permissions" } |
452 |
} |
453 |
); |
454 |
|
455 |
$t->delete_ok( "//$userid:$password@/api/v1/checkouts" => json => |
456 |
{ item_id => $item1_id, patron_id => $library_id } )->status_is(400) |
457 |
->json_is( |
458 |
'/error' => 'Item not checked out' ); |
459 |
|
460 |
AddIssue( $patron, $item1->barcode ); |
461 |
$t->delete_ok( "//$userid:$password@/api/v1/checkouts" => json => |
462 |
{ item_id => $item1_id, patron_id => $library_id } )->status_is(201); |
463 |
|
464 |
$item1->delete; |
465 |
$t->delete_ok( "//$userid:$password@/api/v1/checkouts/" => json => |
466 |
{ item_id => $item1_id, patron_id => $library_id } )->status_is(409) |
467 |
->json_is( |
468 |
'/error' => 'Item not found' ); |
469 |
$schema->storage->txn_rollback; |
470 |
}; |