From 4eee0de8c7dea008038f3289c4c06d7ea80983ac Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 2 Mar 2023 11:45:12 -0300 Subject: [PATCH] Bug 32997: (QA follow-up) values => authorised_values This patch renames that for consistency, and also makes use of the ->authorised_values accessor on the category. Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 2d31e83f37d325754ba468f5c05033ec76843988) Signed-off-by: Matt Blenkinsop --- Koha/REST/V1/AuthorisedValues.pm | 3 +-- api/v1/swagger/paths/authorised_values.yaml | 2 +- api/v1/swagger/swagger.yaml | 4 ++-- t/db_dependent/api/v1/authorised_values.t | 8 ++++---- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Koha/REST/V1/AuthorisedValues.pm b/Koha/REST/V1/AuthorisedValues.pm index add0fa5910..56ce3277e6 100644 --- a/Koha/REST/V1/AuthorisedValues.pm +++ b/Koha/REST/V1/AuthorisedValues.pm @@ -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 { diff --git a/api/v1/swagger/paths/authorised_values.yaml b/api/v1/swagger/paths/authorised_values.yaml index 243729ceb7..298f3ec229 100644 --- a/api/v1/swagger/paths/authorised_values.yaml +++ b/api/v1/swagger/paths/authorised_values.yaml @@ -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 diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml index cc3e1873a3..c728f9d6d7 100644 --- a/api/v1/swagger/swagger.yaml +++ b/api/v1/swagger/swagger.yaml @@ -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": diff --git a/t/db_dependent/api/v1/authorised_values.t b/t/db_dependent/api/v1/authorised_values.t index cb6d829821..187087d440 100755 --- a/t/db_dependent/api/v1/authorised_values.t +++ b/t/db_dependent/api/v1/authorised_values.t @@ -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; -- 2.39.5