Bugzilla – Attachment 151181 Details for
Bug 24401
REST API: Check-in
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24401: REST API: Checkin unit test fixes
Bug-24401-REST-API-Checkin-unit-test-fixes.patch (text/plain), 7.57 KB, created by
Alex Buckley
on 2023-05-15 05:49:36 UTC
(
hide
)
Description:
Bug 24401: REST API: Checkin unit test fixes
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2023-05-15 05:49:36 UTC
Size:
7.57 KB
patch
obsolete
>From e0a6576f46df346c7971e612d1a9d1b1ddfe698f Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Mon, 15 May 2023 05:47:57 +0000 >Subject: [PATCH] Bug 24401: REST API: Checkin unit test fixes > >Sponsored-by: Auckland University of Technology >--- > C4/Circulation.pm | 1 + > Koha/Illbackends/FreeForm | 1 + > Koha/REST/V1/Checkouts.pm | 3 +-- > api/v1/swagger/paths/checkouts.yaml | 12 ++++++++--- > api/v1/swagger/swagger.yaml | 2 -- > t/db_dependent/api/v1/checkouts.t | 31 ++++++++++++++++++----------- > 6 files changed, 31 insertions(+), 19 deletions(-) > create mode 160000 Koha/Illbackends/FreeForm > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index cfdc21e1cb9..76269be3d7b 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -1539,6 +1539,7 @@ sub AddIssue { > # check if we just renew the issue. > if ( $actualissue and $actualissue->borrowernumber eq $borrower->{'borrowernumber'} > and not $switch_onsite_checkout ) { >+ > $datedue = AddRenewal( > $borrower->{'borrowernumber'}, > $item_object->itemnumber, >diff --git a/Koha/Illbackends/FreeForm b/Koha/Illbackends/FreeForm >new file mode 160000 >index 00000000000..71409f3f23d >--- /dev/null >+++ b/Koha/Illbackends/FreeForm >@@ -0,0 +1 @@ >+Subproject commit 71409f3f23d195cc9cb1a34a1adc59518e9ea0f6 >diff --git a/Koha/REST/V1/Checkouts.pm b/Koha/REST/V1/Checkouts.pm >index 654454af463..b543208cd55 100644 >--- a/Koha/REST/V1/Checkouts.pm >+++ b/Koha/REST/V1/Checkouts.pm >@@ -25,7 +25,7 @@ use Encode; > > use C4::Auth qw( haspermission ); > use C4::Context; >-use C4::Circulation qw( AddIssue AddRenewal ); >+use C4::Circulation qw( AddIssue AddRenewal CanBookBeRenewed ); > use Koha::Checkouts; > use Koha::Old::Checkouts; > >@@ -272,7 +272,6 @@ sub delete { > > my $body = $c->validation->param('body'); > my $item_id = $body->{item_id}; >- > return try { > my $item = Koha::Items->find($item_id); > unless ($item) { >diff --git a/api/v1/swagger/paths/checkouts.yaml b/api/v1/swagger/paths/checkouts.yaml >index 8f90c568b4c..aa17f419a8d 100644 >--- a/api/v1/swagger/paths/checkouts.yaml >+++ b/api/v1/swagger/paths/checkouts.yaml >@@ -124,15 +124,21 @@ > permissions: > circulate: circulate_remaining_permissions > delete: >- x-mojo-to: Checkout#delete >+ x-mojo-to: Checkouts#delete > operationId: deletecheckout > tags: > - checkouts > - items > summary: Check in an item > parameters: >- - $ref: "../swagger.yaml#/parameters/item_id_pp" >- - $ref: "../swagger.yaml#/parameters/library_id_qp" >+ - name: body >+ in: body >+ description: A JSON object containing information about the checkout >+ required: true >+ schema: >+ $ref: "../swagger.yaml#/definitions/checkout" >+ consumes: >+ - application/json > produces: > - application/json > responses: >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index 57db5f2514a..6547459c737 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -199,8 +199,6 @@ paths: > $ref: "./paths/checkouts.yaml#/~1checkouts~1{checkout_id}~1renewal" > "/checkouts/availability": > $ref: "./paths/checkouts.yaml#/~1checkouts~1availability" >- "/checkouts/{item_id}": >- $ref: "./paths/checkouts.yaml#/~1checkouts~1{item_id}" > /circulation-rules/kinds: > $ref: ./paths/circulation-rules.yaml#/~1circulation-rules~1kinds > /cities: >diff --git a/t/db_dependent/api/v1/checkouts.t b/t/db_dependent/api/v1/checkouts.t >index 6e4aac035ca..b8b93b8eb06 100755 >--- a/t/db_dependent/api/v1/checkouts.t >+++ b/t/db_dependent/api/v1/checkouts.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 101; >+use Test::More tests => 102; > use Test::MockModule; > use Test::Mojo; > use t::lib::Mocks; >@@ -253,6 +253,7 @@ subtest 'get_availability' => sub { > my $patron = $builder->build_object( > { > class => 'Koha::Patrons', >+ > value => { flags => 0 } > } > ); >@@ -325,6 +326,7 @@ subtest 'get_availability' => sub { > )->status_is(200)->json_is( '/blockers' => {} ) > ->json_is( '/confirms' => { confirm1 => 1, confirm2 => 'please' } ) > ->json_is( '/warnings' => {} ) >+ > ->json_is( '/confirmation_token' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb25maXJtMSI6MSwiY29uZmlybTIiOjF9.4QBpITwnIGOAfohyKjaFDoeBWnGmQTdyJrPn9pavArw' ); > > $schema->storage->txn_rollback; >@@ -349,6 +351,7 @@ subtest 'add checkout' => sub { > { > class => 'Koha::Patrons', > value => { flags => 0 } >+ > } > ); > my $unauth_password = 'thePassword000'; >@@ -362,6 +365,9 @@ subtest 'add checkout' => sub { > my $item1 = $builder->build_sample_item; > my $item1_id = $item1->id; > >+ my $item2 = $builder->build_sample_item; >+ my $item2_id = $item2->id; >+ > my %issuingimpossible = (); > my %needsconfirmation = (); > my %alerts = (); >@@ -399,8 +405,9 @@ subtest 'add checkout' => sub { > > my $token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb25maXJtMSI6MSwiY29uZmlybTIiOjF9.4QBpITwnIGOAfohyKjaFDoeBWnGmQTdyJrPn9pavArw"; > $t->post_ok( >+ > "//$userid:$password@/api/v1/checkouts?confirmation=$token" => json => { >- item_id => $item1_id, >+ item_id => $item2_id, > patron_id => $patron_id > } > )->status_is(201)->or(sub { diag $t->tx->res->body }); >@@ -411,7 +418,7 @@ subtest 'add checkout' => sub { > > subtest 'delete checkout' => sub { > >- plan tests => 4; >+ plan tests => 11; > > $schema->storage->txn_begin; > my $librarian = $builder->build_object( >@@ -435,36 +442,36 @@ subtest 'delete checkout' => sub { > { password => $unauth_password, skip_validattion => 1 } ); > my $unauth_userid = $patron->userid; > >- my $branch = $builder->build_sample_branch; >+ my $branch = $builder->build_object( { class => 'Koha::Libraries' } ); > my $library_id = $branch->id; >- my $item1 = $builder->build_sample_item; >- my $item1_id = $item1->id; >- >+ my $item1 = $builder->build_sample_item; >+ my $item1_id = $item1->id; > > $t->delete_ok( > "//$unauth_userid:$unauth_password@/api/v1/checkouts" => json => > { item_id => $item1_id, library_id => $library_id } )->status_is(403) > ->json_is( > { >- error => "checkin not allowed", >+ error => "Authorization failure. Missing required permission(s).", > required_permissions => > { circulate => "circulate_remaining_permissions" } > } > ); > > $t->delete_ok( "//$userid:$password@/api/v1/checkouts" => json => >- { item_id => $item1_id, patron_id => $library_id } )->status_is(400) >+ { item_id => $item1_id, library_id => $library_id } )->status_is(400) > ->json_is( > '/error' => 'Item not checked out' ); > >- AddIssue( $patron, $item1->barcode ); >+ AddIssue( $patron->unblessed, $item1->barcode ); > $t->delete_ok( "//$userid:$password@/api/v1/checkouts" => json => >- { item_id => $item1_id, patron_id => $library_id } )->status_is(201); >+ { item_id => $item1_id, library_id => $library_id } )->status_is(201); > > $item1->delete; > $t->delete_ok( "//$userid:$password@/api/v1/checkouts/" => json => >- { item_id => $item1_id, patron_id => $library_id } )->status_is(409) >+ { item_id => $item1_id, library_id => $library_id } )->status_is(409) > ->json_is( > '/error' => 'Item not found' ); >+ > $schema->storage->txn_rollback; > }; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24401
:
151109
|
151181
|
151182
|
151183
|
151184
|
152717
|
154428
|
154429
|
154430
|
154431
|
156884
|
156885