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 <tomascohen@theke.io>
(cherry picked from commit 2d31e83f37)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
Tomás Cohen Arazi 2023-03-02 11:45:12 -03:00 committed by Matt Blenkinsop
parent 88aa0bb115
commit 4eee0de8c7
4 changed files with 8 additions and 9 deletions

View 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 {

View 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

View 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":

View file

@ -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;