Bug 32997: (QA follow-up) values => authorised_values
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 2 Mar 2023 14:45:12 +0000 (11:45 -0300)
committerTomas Cohen Arazi <tomascohen@theke.io>
Thu, 2 Mar 2023 15:00:17 +0000 (12:00 -0300)
This patch renames that for consistency, and also makes use of the
->authorised_values accessor on the category.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Koha/REST/V1/AuthorisedValues.pm
api/v1/swagger/paths/authorised_values.yaml
api/v1/swagger/swagger.yaml
t/db_dependent/api/v1/authorised_values.t

index add0fa5..56ce327 100644 (file)
@@ -19,7 +19,6 @@ use Modern::Perl;
 
 use Mojo::Base 'Mojolicious::Controller';
 
-use Koha::AuthorisedValues;
 use Koha::AuthorisedValueCategories;
 
 use Try::Tiny;
@@ -49,7 +48,7 @@ sub list_av_from_category {
     }
 
     return try {
-        my $av_set = Koha::AuthorisedValues->search( { category => $category_name } )->search_with_library_limits;
+        my $av_set = $category->authorised_values->search_with_library_limits;
         my $avs    = $c->objects->search($av_set);
         return $c->render( status => 200, openapi => $avs );
     } catch {
index 243729c..298f3ec 100644 (file)
@@ -1,5 +1,5 @@
 ---
-"/authorised_value_categories/{authorised_value_category_name}/values":
+"/authorised_value_categories/{authorised_value_category_name}/authorised_values":
   get:
     x-mojo-to: AuthorisedValues#list_av_from_category
     operationId: listAuthorisedValues
index cc3e187..c728f9d 100644 (file)
@@ -145,8 +145,8 @@ paths:
     $ref: paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1domains~1{identity_provider_domain_id}
   /authorised_value_categories:
     $ref: paths/authorised_value_categories.yaml#/~1authorised_value_categories
-  "/authorised_value_categories/{authorised_value_category_name}/values":
-    $ref: "./paths/authorised_values.yaml#/~1authorised_value_categories~1{authorised_value_category_name}~1values"
+  "/authorised_value_categories/{authorised_value_category_name}/authorised_values":
+    $ref: "./paths/authorised_values.yaml#/~1authorised_value_categories~1{authorised_value_category_name}~1authorised_values"
   "/biblios/{biblio_id}":
     $ref: "./paths/biblios.yaml#/~1biblios~1{biblio_id}"
   "/biblios/{biblio_id}/checkouts":
index cb6d829..187087d 100755 (executable)
@@ -60,14 +60,14 @@ subtest 'list_av_from_category() tests' => sub {
 
     ## Authorized user tests
     # No category, 404 expected
-    $t->get_ok("//$userid:$password@/api/v1/authorised_value_categories/NON_EXISTS/values")
+    $t->get_ok("//$userid:$password@/api/v1/authorised_value_categories/NON_EXISTS/authorised_values")
       ->status_is(404)
       ->json_is( '/error' => 'Category not found' );
 
     my $av_cat = $builder->build_object({ class => 'Koha::AuthorisedValueCategories' })->category_name;
 
     # No AVs, so empty array should be returned
-    $t->get_ok("//$userid:$password@/api/v1/authorised_value_categories/$av_cat/values")
+    $t->get_ok("//$userid:$password@/api/v1/authorised_value_categories/$av_cat/authorised_values")
       ->status_is(200)
       ->json_is( [] );
 
@@ -75,12 +75,12 @@ subtest 'list_av_from_category() tests' => sub {
         { class => 'Koha::AuthorisedValues', value => { category => $av_cat } } );
 
     # One av created, should get returned
-    $t->get_ok("//$userid:$password@/api/v1/authorised_value_categories/$av_cat/values")
+    $t->get_ok("//$userid:$password@/api/v1/authorised_value_categories/$av_cat/authorised_values")
       ->status_is(200)
       ->json_is( [$av->to_api] );
 
     # Unauthorized access
-    $t->get_ok("//$unauth_userid:$password@/api/v1/authorised_value_categories/$av_cat/values")
+    $t->get_ok("//$unauth_userid:$password@/api/v1/authorised_value_categories/$av_cat/authorised_values")
       ->status_is(403);
 
     $schema->storage->txn_rollback;