Lines 473-479
subtest 'add checkout' => sub {
Link Here
|
473 |
my $token = Koha::Token->new->generate_jwt( { id => $librarian->id . ":" . $item1_id . ":confirm1:confirm2" } ); |
473 |
my $token = Koha::Token->new->generate_jwt( { id => $librarian->id . ":" . $item1_id . ":confirm1:confirm2" } ); |
474 |
$t->post_ok( |
474 |
$t->post_ok( |
475 |
"//$userid:$password@/api/v1/checkouts?confirmation=$token" => json => { |
475 |
"//$userid:$password@/api/v1/checkouts?confirmation=$token" => json => { |
476 |
item_id => $item2_id, |
476 |
item_id => $item1_id, |
477 |
patron_id => $patron_id |
477 |
patron_id => $patron_id |
478 |
} |
478 |
} |
479 |
)->status_is(201)->or( sub { diag $t->tx->res->body } ); |
479 |
)->status_is(201)->or( sub { diag $t->tx->res->body } ); |
Lines 540-579
subtest 'delete checkout' => sub {
Link Here
|
540 |
} |
540 |
} |
541 |
); |
541 |
); |
542 |
my $unauth_password = 'thePassword000'; |
542 |
my $unauth_password = 'thePassword000'; |
543 |
$patron->set_password( |
543 |
$patron->set_password( { password => $unauth_password, skip_validattion => 1 } ); |
544 |
{ password => $unauth_password, skip_validattion => 1 } ); |
|
|
545 |
my $unauth_userid = $patron->userid; |
544 |
my $unauth_userid = $patron->userid; |
546 |
|
545 |
|
547 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
546 |
my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); |
548 |
my $library_id = $branch->id; |
547 |
my $library_id = $branch->id; |
549 |
my $item1 = $builder->build_sample_item; |
548 |
my $item1 = $builder->build_sample_item; |
550 |
my $item1_id = $item1->id; |
549 |
my $item1_id = $item1->id; |
551 |
|
550 |
|
552 |
|
551 |
$t->delete_ok( "//$unauth_userid:$unauth_password@/api/v1/checkouts" => json => |
553 |
$t->delete_ok( |
552 |
{ item_id => $item1_id, library_id => $library_id } )->status_is(403)->json_is( |
554 |
"//$unauth_userid:$unauth_password@/api/v1/checkouts" => json => |
|
|
555 |
{ item_id => $item1_id, library_id => $library_id } )->status_is(403) |
556 |
->json_is( |
557 |
{ |
553 |
{ |
558 |
error => "Authorization failure. Missing required permission(s).", |
554 |
error => "Authorization failure. Missing required permission(s).", |
559 |
required_permissions => |
555 |
required_permissions => { circulate => "circulate_remaining_permissions" } |
560 |
{ circulate => "circulate_remaining_permissions" } |
|
|
561 |
} |
556 |
} |
562 |
); |
557 |
); |
563 |
|
558 |
|
564 |
$t->delete_ok( "//$userid:$password@/api/v1/checkouts" => json => |
559 |
$t->delete_ok( |
565 |
{ item_id => $item1_id, library_id => $library_id } )->status_is(400) |
560 |
"//$userid:$password@/api/v1/checkouts" => json => { item_id => $item1_id, library_id => $library_id } ) |
566 |
->json_is( |
561 |
->status_is(400)->json_is( '/error' => 'Item not checked out' ); |
567 |
'/error' => 'Item not checked out' ); |
|
|
568 |
|
562 |
|
569 |
AddIssue( $patron->unblessed, $item1->barcode ); |
563 |
AddIssue( $patron->unblessed, $item1->barcode ); |
570 |
$t->delete_ok( "//$userid:$password@/api/v1/checkouts" => json => |
564 |
$t->delete_ok( |
571 |
{ item_id => $item1_id, library_id => $library_id } )->status_is(201); |
565 |
"//$userid:$password@/api/v1/checkouts" => json => { item_id => $item1_id, library_id => $library_id } ) |
|
|
566 |
->status_is(201); |
572 |
|
567 |
|
573 |
$item1->delete; |
568 |
$item1->delete; |
574 |
$t->delete_ok( "//$userid:$password@/api/v1/checkouts/" => json => |
569 |
$t->delete_ok( |
575 |
{ item_id => $item1_id, library_id => $library_id } )->status_is(409) |
570 |
"//$userid:$password@/api/v1/checkouts/" => json => { item_id => $item1_id, library_id => $library_id } ) |
576 |
->json_is( |
571 |
->status_is(409)->json_is( '/error' => 'Item not found' ); |
577 |
'/error' => 'Item not found' ); |
|
|
578 |
$schema->storage->txn_rollback; |
572 |
$schema->storage->txn_rollback; |
579 |
}; |
573 |
}; |
580 |
- |
|
|