From 7f8bf3041b397ce5a2ebcb5e21fdaba061b6e935 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 10 Oct 2023 10:47:21 +0000 Subject: [PATCH] Bug 30719: QA follow-up: Rename illbatchstatuses illbatchstatuses endpoint is now ill/batchstatuses --- Koha/REST/V1/IllbatchStatuses.pm | 6 ++-- ...lbatchstatus.yaml => ill_batchstatus.yaml} | 0 ...chstatuses.yaml => ill_batchstatuses.yaml} | 2 +- ...chstatuses.yaml => ill_batchstatuses.yaml} | 32 ++++++++--------- api/v1/swagger/swagger.yaml | 22 ++++++------ .../intranet-tmpl/prog/js/ill-batch-modal.js | 2 +- ...illbatchstatuses.t => ill_batchstatuses.t} | 36 +++++++++---------- 7 files changed, 50 insertions(+), 50 deletions(-) rename api/v1/swagger/definitions/{illbatchstatus.yaml => ill_batchstatus.yaml} (100%) rename api/v1/swagger/definitions/{illbatchstatuses.yaml => ill_batchstatuses.yaml} (62%) rename api/v1/swagger/paths/{illbatchstatuses.yaml => ill_batchstatuses.yaml} (88%) rename t/db_dependent/api/v1/{illbatchstatuses.t => ill_batchstatuses.t} (80%) diff --git a/Koha/REST/V1/IllbatchStatuses.pm b/Koha/REST/V1/IllbatchStatuses.pm index b2ed518b88..1527dd3875 100644 --- a/Koha/REST/V1/IllbatchStatuses.pm +++ b/Koha/REST/V1/IllbatchStatuses.pm @@ -50,7 +50,7 @@ Get one batch statuses sub get { my $c = shift->openapi->valid_input; - my $status_code = $c->param('illbatchstatus_code'); + my $status_code = $c->param('ill_batchstatus_code'); my $status = Koha::IllbatchStatuses->find( { code => $status_code } ); @@ -107,7 +107,7 @@ Update a batch status sub update { my $c = shift->openapi->valid_input or return; - my $status = Koha::IllbatchStatuses->find( { code => $c->param('illbatchstatus_code') } ); + my $status = Koha::IllbatchStatuses->find( { code => $c->param('ill_batchstatus_code') } ); if ( not defined $status ) { return $c->render( @@ -142,7 +142,7 @@ sub delete { my $c = shift->openapi->valid_input or return; - my $status = Koha::IllbatchStatuses->find( { code => $c->param('illbatchstatus_code') } ); + my $status = Koha::IllbatchStatuses->find( { code => $c->param('ill_batchstatus_code') } ); if ( not defined $status ) { return $c->render( status => 404, openapi => { errors => [ { message => "ILL batch status not found" } ] } ); diff --git a/api/v1/swagger/definitions/illbatchstatus.yaml b/api/v1/swagger/definitions/ill_batchstatus.yaml similarity index 100% rename from api/v1/swagger/definitions/illbatchstatus.yaml rename to api/v1/swagger/definitions/ill_batchstatus.yaml diff --git a/api/v1/swagger/definitions/illbatchstatuses.yaml b/api/v1/swagger/definitions/ill_batchstatuses.yaml similarity index 62% rename from api/v1/swagger/definitions/illbatchstatuses.yaml rename to api/v1/swagger/definitions/ill_batchstatuses.yaml index 5eb4b53400..88e69cbe7a 100644 --- a/api/v1/swagger/definitions/illbatchstatuses.yaml +++ b/api/v1/swagger/definitions/ill_batchstatuses.yaml @@ -1,5 +1,5 @@ --- type: array items: - $ref: "illbatchstatus.yaml" + $ref: "ill_batchstatus.yaml" additionalProperties: false diff --git a/api/v1/swagger/paths/illbatchstatuses.yaml b/api/v1/swagger/paths/ill_batchstatuses.yaml similarity index 88% rename from api/v1/swagger/paths/illbatchstatuses.yaml rename to api/v1/swagger/paths/ill_batchstatuses.yaml index f211b2b62d..235a5600b2 100644 --- a/api/v1/swagger/paths/illbatchstatuses.yaml +++ b/api/v1/swagger/paths/ill_batchstatuses.yaml @@ -1,10 +1,10 @@ --- -/illbatchstatuses: +/ill/batchstatuses: get: x-mojo-to: IllbatchStatuses#list operationId: listIllbatchstatuses tags: - - illbatchstatuses + - ill_batchstatuses summary: List ILL batch statuses parameters: [] produces: @@ -13,7 +13,7 @@ "200": description: A list of ILL batch statuses schema: - $ref: "../swagger.yaml#/definitions/illbatchstatuses" + $ref: "../swagger.yaml#/definitions/ill_batchstatuses" "401": description: Authentication required schema: @@ -44,7 +44,7 @@ x-mojo-to: IllbatchStatuses#add operationId: addIllbatchstatus tags: - - illbatchstatuses + - ill_batchstatuses summary: Add ILL batch status parameters: - name: body @@ -52,14 +52,14 @@ description: A JSON object containing informations about the new batch status required: true schema: - $ref: "../swagger.yaml#/definitions/illbatchstatus" + $ref: "../swagger.yaml#/definitions/ill_batchstatus" produces: - application/json responses: "201": description: Batch status added schema: - $ref: "../swagger.yaml#/definitions/illbatchstatus" + $ref: "../swagger.yaml#/definitions/ill_batchstatus" "400": description: Bad request schema: @@ -90,15 +90,15 @@ x-koha-authorization: permissions: ill: "1" -"/illbatchstatuses/{illbatchstatus_code}": +"/ill/batchstatuses/{ill_batchstatus_code}": get: x-mojo-to: IllbatchStatuses#get operationId: getIllbatchstatuses tags: - - illbatchstatuses + - ill_batchstatuses summary: Get ILL batch status parameters: - - name: illbatchstatus_code + - name: ill_batchstatus_code in: path description: ILL batch status required: true @@ -109,7 +109,7 @@ "200": description: An ILL batch status schema: - $ref: "../swagger.yaml#/definitions/illbatchstatus" + $ref: "../swagger.yaml#/definitions/ill_batchstatus" "401": description: Authentication required schema: @@ -140,16 +140,16 @@ x-mojo-to: IllbatchStatuses#update operationId: updateIllBatchstatus tags: - - illbatchstatuses + - ill_batchstatuses summary: Update batch status parameters: - - $ref: "../swagger.yaml#/parameters/illbatchstatus_code_pp" + - $ref: "../swagger.yaml#/parameters/ill_batchstatus_code_pp" - name: body in: body description: A JSON object containing information on the batch status required: true schema: - $ref: "../swagger.yaml#/definitions/illbatchstatus" + $ref: "../swagger.yaml#/definitions/ill_batchstatus" consumes: - application/json produces: @@ -158,7 +158,7 @@ "200": description: An ILL batch status schema: - $ref: "../swagger.yaml#/definitions/illbatchstatus" + $ref: "../swagger.yaml#/definitions/ill_batchstatus" "400": description: Bad request schema: @@ -193,10 +193,10 @@ x-mojo-to: IllbatchStatuses#delete operationId: deleteBatchstatus tags: - - illbatchstatuses + - ill_batchstatuses summary: Delete ILL batch status parameters: - - $ref: "../swagger.yaml#/parameters/illbatchstatus_code_pp" + - $ref: "../swagger.yaml#/parameters/ill_batchstatus_code_pp" produces: - application/json responses: diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml index 3a6320528c..985e20d9d8 100644 --- a/api/v1/swagger/swagger.yaml +++ b/api/v1/swagger/swagger.yaml @@ -68,10 +68,10 @@ definitions: $ref: ./definitions/ill_batch.yaml ill_batches: $ref: ./definitions/ill_batches.yaml - illbatchstatus: - $ref: ./definitions/illbatchstatus.yaml - illbatchstatuses: - $ref: ./definitions/illbatchstatuses.yaml + ill_batchstatus: + $ref: ./definitions/ill_batchstatus.yaml + ill_batchstatuses: + $ref: ./definitions/ill_batchstatuses.yaml import_batch_profile: $ref: ./definitions/import_batch_profile.yaml import_batch_profiles: @@ -281,10 +281,10 @@ paths: $ref: ./paths/ill_batches.yaml#/~1ill~1batches "/ill/batches/{ill_batch_id}": $ref: "./paths/ill_batches.yaml#/~1ill~1batches~1{ill_batch_id}" - /illbatchstatuses: - $ref: ./paths/illbatchstatuses.yaml#/~1illbatchstatuses - "/illbatchstatuses/{illbatchstatus_code}": - $ref: "./paths/illbatchstatuses.yaml#/~1illbatchstatuses~1{illbatchstatus_code}" + /ill/batchstatuses: + $ref: ./paths/ill_batchstatuses.yaml#/~1ill~1batchstatuses + "/ill/batchstatuses/{ill_batchstatus_code}": + $ref: "./paths/ill_batchstatuses.yaml#/~1ill~1batchstatuses~1{ill_batchstatus_code}" "/import_batches/{import_batch_id}/records/{import_record_id}/matches/chosen": $ref: "./paths/import_batches.yaml#/~1import_batches~1{import_batch_id}~1records~1{import_record_id}~1matches~1chosen" /import_batch_profiles: @@ -543,10 +543,10 @@ parameters: name: ill_batch_id required: true type: integer - illbatchstatus_code_pp: + ill_batchstatus_code_pp: description: Internal ILL batch status identifier in: path - name: illbatchstatus_code + name: ill_batchstatus_code required: true type: string import_batch_profile_id_pp: @@ -883,7 +883,7 @@ tags: name: ill_batches x-displayName: ILL batches - description: "Manage ILL module batch statuses\n" - name: illbatchstatuses + name: ill_batchstatuses x-displayName: ILL batch statuses - description: "Manage ILL requests\n" name: ill_requests diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js b/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js index 1b8a4ab8b0..c7c302b1aa 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js +++ b/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js @@ -485,7 +485,7 @@ // Get all batch statuses function fetchStatuses() { - window.doApiRequest('/api/v1/illbatchstatuses') + window.doApiRequest('/api/v1/ill/batchstatuses') .then(function (response) { return response.json(); }) diff --git a/t/db_dependent/api/v1/illbatchstatuses.t b/t/db_dependent/api/v1/ill_batchstatuses.t similarity index 80% rename from t/db_dependent/api/v1/illbatchstatuses.t rename to t/db_dependent/api/v1/ill_batchstatuses.t index 2bfce7f898..55354ddcc8 100755 --- a/t/db_dependent/api/v1/illbatchstatuses.t +++ b/t/db_dependent/api/v1/ill_batchstatuses.t @@ -56,7 +56,7 @@ subtest 'list() tests' => sub { ## Authorized user tests # No statuses, so empty array should be returned - $t->get_ok("//$userid:$password@/api/v1/illbatchstatuses")->status_is(200)->json_is( [] ); + $t->get_ok("//$userid:$password@/api/v1/ill/batchstatuses")->status_is(200)->json_is( [] ); my $status = $builder->build_object( { @@ -70,7 +70,7 @@ subtest 'list() tests' => sub { ); # One batch created, should get returned - $t->get_ok("//$userid:$password@/api/v1/illbatchstatuses")->status_is(200)->json_has( '/0/id', 'ID' ) + $t->get_ok("//$userid:$password@/api/v1/ill/batchstatuses")->status_is(200)->json_has( '/0/id', 'ID' ) ->json_has( '/0/name', 'Name' )->json_has( '/0/code', 'Code' )->json_has( '/0/is_system', 'is_system' ); $schema->storage->txn_rollback; @@ -113,17 +113,17 @@ subtest 'get() tests' => sub { $patron->set_password( { password => $password, skip_validation => 1 } ); my $unauth_userid = $patron->userid; - $t->get_ok( "//$userid:$password@/api/v1/illbatchstatuses/" . $status->code )->status_is(200) + $t->get_ok( "//$userid:$password@/api/v1/ill/batchstatuses/" . $status->code )->status_is(200) ->json_has( '/id', 'ID' )->json_has( '/name', 'Name' )->json_has( '/code', 'Code' ) ->json_has( '/is_system', 'is_system' ); - $t->get_ok( "//$unauth_userid:$password@/api/v1/illbatchstatuses/" . $status->id )->status_is(403); + $t->get_ok( "//$unauth_userid:$password@/api/v1/ill/batchstatuses/" . $status->id )->status_is(403); my $status_to_delete = $builder->build_object( { class => 'Koha::IllbatchStatuses' } ); my $non_existent_code = $status_to_delete->code; $status_to_delete->delete; - $t->get_ok("//$userid:$password@/api/v1/illbatchstatuses/$non_existent_code")->status_is(404) + $t->get_ok("//$userid:$password@/api/v1/ill/batchstatuses/$non_existent_code")->status_is(404) ->json_is( '/error' => 'ILL batch status not found' ); $schema->storage->txn_rollback; @@ -161,7 +161,7 @@ subtest 'add() tests' => sub { }; # Unauthorized attempt to write - $t->post_ok( "//$unauth_userid:$password@/api/v1/illbatchstatuses" => json => $status_metadata )->status_is(403); + $t->post_ok( "//$unauth_userid:$password@/api/v1/ill/batchstatuses" => json => $status_metadata )->status_is(403); # Authorized attempt to write invalid data my $status_with_invalid_field = { @@ -169,7 +169,7 @@ subtest 'add() tests' => sub { doh => 1 }; - $t->post_ok( "//$userid:$password@/api/v1/illbatchstatuses" => json => $status_with_invalid_field )->status_is(400) + $t->post_ok( "//$userid:$password@/api/v1/ill/batchstatuses" => json => $status_with_invalid_field )->status_is(400) ->json_is( "/errors" => [ { @@ -181,13 +181,13 @@ subtest 'add() tests' => sub { # Authorized attempt to write my $status_id = - $t->post_ok( "//$userid:$password@/api/v1/illbatchstatuses" => json => $status_metadata )->status_is(201) + $t->post_ok( "//$userid:$password@/api/v1/ill/batchstatuses" => json => $status_metadata )->status_is(201) ->json_has( '/id', 'ID' )->json_has( '/name', 'Name' )->json_has( '/code', 'Code' ) ->json_has( '/is_system', 'is_system' ); # Authorized attempt to create with null id $status_metadata->{id} = undef; - $t->post_ok( "//$userid:$password@/api/v1/illbatchstatuses" => json => $status_metadata )->status_is(400) + $t->post_ok( "//$userid:$password@/api/v1/ill/batchstatuses" => json => $status_metadata )->status_is(400) ->json_has('/errors'); $schema->storage->txn_rollback; @@ -221,7 +221,7 @@ subtest 'update() tests' => sub { my $status_code = $builder->build_object( { class => 'Koha::IllbatchStatuses' } )->code; # Unauthorized attempt to update - $t->put_ok( "//$unauth_userid:$password@/api/v1/illbatchstatuses/$status_code" => json => + $t->put_ok( "//$unauth_userid:$password@/api/v1/ill/batchstatuses/$status_code" => json => { name => 'These are not the droids you are looking for' } )->status_is(403); # Attempt partial update on a PUT @@ -230,7 +230,7 @@ subtest 'update() tests' => sub { is_system => 0 }; - $t->put_ok( "//$userid:$password@/api/v1/illbatchstatuses/$status_code" => json => $status_with_missing_field ) + $t->put_ok( "//$userid:$password@/api/v1/ill/batchstatuses/$status_code" => json => $status_with_missing_field ) ->status_is(400)->json_is( "/errors" => [ { message => "Missing property.", path => "/body/name" } ] ); # Full object update on PUT @@ -240,7 +240,7 @@ subtest 'update() tests' => sub { is_system => 0 }; - $t->put_ok( "//$userid:$password@/api/v1/illbatchstatuses/$status_code" => json => $status_with_updated_field ) + $t->put_ok( "//$userid:$password@/api/v1/ill/batchstatuses/$status_code" => json => $status_with_updated_field ) ->status_is(200)->json_is( '/name' => 'Master Ploo Koon' ); # Authorized attempt to write invalid data @@ -250,7 +250,7 @@ subtest 'update() tests' => sub { code => $status_code }; - $t->put_ok( "//$userid:$password@/api/v1/illbatchstatuses/$status_code" => json => $status_with_invalid_field ) + $t->put_ok( "//$userid:$password@/api/v1/ill/batchstatuses/$status_code" => json => $status_with_invalid_field ) ->status_is(400)->json_is( "/errors" => [ { @@ -265,7 +265,7 @@ subtest 'update() tests' => sub { $status_to_delete->delete; $t->put_ok( - "//$userid:$password@/api/v1/illbatchstatuses/$non_existent_code" => json => $status_with_updated_field ) + "//$userid:$password@/api/v1/ill/batchstatuses/$non_existent_code" => json => $status_with_updated_field ) ->status_is(404); $schema->storage->txn_rollback; @@ -312,13 +312,13 @@ subtest 'delete() tests' => sub { ); # Unauthorized attempt to delete - $t->delete_ok( "//$unauth_userid:$password@/api/v1/illbatchstatuses/" . $non_system_status->code )->status_is(403); + $t->delete_ok( "//$unauth_userid:$password@/api/v1/ill/batchstatuses/" . $non_system_status->code )->status_is(403); - $t->delete_ok( "//$userid:$password@/api/v1/illbatchstatuses/" . $non_system_status->code )->status_is(204); + $t->delete_ok( "//$userid:$password@/api/v1/ill/batchstatuses/" . $non_system_status->code )->status_is(204); - $t->delete_ok( "//$userid:$password@/api/v1/illbatchstatuses/" . $non_system_status->code )->status_is(404); + $t->delete_ok( "//$userid:$password@/api/v1/ill/batchstatuses/" . $non_system_status->code )->status_is(404); - $t->delete_ok( "//$userid:$password@/api/v1/illbatchstatuses/" . $system_status->code )->status_is(400) + $t->delete_ok( "//$userid:$password@/api/v1/ill/batchstatuses/" . $system_status->code )->status_is(400) ->json_is( "/errors" => [ { message => "ILL batch status cannot be deleted" } ] ); $schema->storage->txn_rollback; -- 2.30.2