Bugzilla – Attachment 92986 Details for
Bug 23517
Add API route to update a holds priority
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23517: Add a spec for PUT /holds/{hold_id}/priority
Bug-23517-Add-a-spec-for-PUT-holdsholdidpriority.patch (text/plain), 6.65 KB, created by
Liz Rea
on 2019-09-19 19:29:18 UTC
(
hide
)
Description:
Bug 23517: Add a spec for PUT /holds/{hold_id}/priority
Filename:
MIME Type:
Creator:
Liz Rea
Created:
2019-09-19 19:29:18 UTC
Size:
6.65 KB
patch
obsolete
>From e04427e3690b85dd78dbe03bfc00b7c38be9a2bd Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 3 Sep 2019 16:39:08 -0300 >Subject: [PATCH] Bug 23517: Add a spec for PUT /holds/{hold_id}/priority > >This patch adds the OpenAPI spec for the endpoint, and tests for the >desired behaviour. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Liz Rea <wizzyrea@gmail.com> >--- > api/v1/swagger/paths.json | 3 ++ > api/v1/swagger/paths/holds.json | 76 +++++++++++++++++++++++++++++++++++ > t/db_dependent/api/v1/holds.t | 88 ++++++++++++++++++++++++++++++++++++++++- > 3 files changed, 166 insertions(+), 1 deletion(-) > >diff --git a/api/v1/swagger/paths.json b/api/v1/swagger/paths.json >index 946de0a6a4..14b36cd1a1 100644 >--- a/api/v1/swagger/paths.json >+++ b/api/v1/swagger/paths.json >@@ -35,6 +35,9 @@ > "/holds/{hold_id}": { > "$ref": "paths/holds.json#/~1holds~1{hold_id}" > }, >+ "/holds/{hold_id}/priority": { >+ "$ref": "paths/holds.json#/~1holds~1{hold_id}~1priority" >+ }, > "/holds/{hold_id}/suspension": { > "$ref": "paths/holds.json#/~1holds~1{hold_id}~1suspension" > }, >diff --git a/api/v1/swagger/paths/holds.json b/api/v1/swagger/paths/holds.json >index 14d29b352d..2bb0ed0179 100644 >--- a/api/v1/swagger/paths/holds.json >+++ b/api/v1/swagger/paths/holds.json >@@ -399,6 +399,82 @@ > } > } > }, >+ "/holds/{hold_id}/priority": { >+ "put": { >+ "x-mojo-to": "Holds#update_priority", >+ "operationId": "updateHoldPriority", >+ "tags": [ >+ "biblios", >+ "holds" >+ ], >+ "parameters": [ >+ { >+ "$ref": "../parameters.json#/hold_id_pp" >+ }, >+ { >+ "name": "body", >+ "in": "body", >+ "description": "An integer representing the new priority to be set for the hold", >+ "required": true, >+ "schema": { >+ "type": "integer" >+ } >+ } >+ ], >+ "produces": [ >+ "application/json" >+ ], >+ "responses": { >+ "200": { >+ "description": "The new priority value for the hold", >+ "schema": { >+ "type": "integer" >+ } >+ }, >+ "401": { >+ "description": "Authentication required", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ }, >+ "403": { >+ "description": "Access forbidden", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ }, >+ "404": { >+ "description": "Biblio not found", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ }, >+ "409": { >+ "description": "Unable to perform action on biblio", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ }, >+ "500": { >+ "description": "Internal error", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ }, >+ "503": { >+ "description": "Under maintenance", >+ "schema": { >+ "$ref": "../definitions.json#/error" >+ } >+ } >+ }, >+ "x-koha-authorization": { >+ "permissions": { >+ "reserveforothers": "modify_holds_priority" >+ } >+ } >+ } >+ }, > "/holds/{hold_id}/suspension": { > "post": { > "x-mojo-to": "Holds#suspend", >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index 1374a7b159..4208eb6225 100644 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 6; > use Test::Mojo; > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -405,6 +405,92 @@ subtest 'suspend and resume tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'PUT /holds/{hold_id}/priority tests' => sub { >+ >+ plan tests => 8; >+ >+ $schema->storage->txn_begin; >+ >+ my $password = 'AbcdEFG123'; >+ >+ my $patron_np = $builder->build_object( >+ { class => 'Koha::Patrons', value => { flags => 0 } } ); >+ $patron_np->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid_np = $patron_np->userid; >+ >+ my $patron = $builder->build_object( >+ { class => 'Koha::Patrons', value => { flags => 0 } } ); >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ my $userid = $patron->userid; >+ $builder->build( >+ { >+ source => 'UserPermission', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ module_bit => 6, >+ code => 'modify_holds_priority', >+ }, >+ } >+ ); >+ >+ # Disable logging >+ t::lib::Mocks::mock_preference( 'HoldsLog', 0 ); >+ t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); >+ >+ my $biblio = $builder->build_sample_biblio; >+ >+ my $hold_1 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ suspend => 0, >+ suspend_until => undef, >+ waitingdate => undef, >+ biblionumber => $biblio->biblionumber, >+ priority => 1 >+ } >+ } >+ ); >+ my $hold_2 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ suspend => 0, >+ suspend_until => undef, >+ waitingdate => undef, >+ biblionumber => $biblio->biblionumber, >+ priority => 2 >+ } >+ } >+ ); >+ my $hold_3 = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ suspend => 0, >+ suspend_until => undef, >+ waitingdate => undef, >+ biblionumber => $biblio->biblionumber, >+ priority => 3 >+ } >+ } >+ ); >+ >+ $t->put_ok( "//$userid_np:$password@/api/v1/holds/" >+ . $hold_3->id >+ . "/priority" => json => 1 )->status_is(403); >+ >+ $t->put_ok( "//$userid:$password@/api/v1/holds/" >+ . $hold_3->id >+ . "/priority" => json => 1 )->status_is(200)->json_is(1); >+ >+ is( $hold_1->discard_changes->priority, 2, 'Priority adjusted correctly' ); >+ is( $hold_2->discard_changes->priority, 3, 'Priority adjusted correctly' ); >+ is( $hold_3->discard_changes->priority, 1, 'Priority adjusted correctly' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > sub create_biblio { > my ($title) = @_; > >-- >2.11.0
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 23517
:
92588
|
92589
|
92590
|
92710
|
92711
|
92712
|
92836
|
92927
|
92928
|
92929
|
92930
| 92986 |
92987
|
92988
|
92989
|
93143