Bug 34008: (QA follow-up) 'item_type_id' should be used
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 05f0604d60
)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
02ad2a271d
commit
0438f8fbb5
4 changed files with 11 additions and 16 deletions
|
@ -221,14 +221,12 @@ on the API.
|
|||
=cut
|
||||
|
||||
sub to_api_mapping {
|
||||
return { 'itemtype' => 'item_type' };
|
||||
return { 'itemtype' => 'item_type_id' };
|
||||
}
|
||||
|
||||
sub from_api_mapping {
|
||||
return { 'item_type' => 'itemtype' };
|
||||
}
|
||||
=head2 Internal methods
|
||||
|
||||
=head3 type
|
||||
=head3 _type
|
||||
|
||||
=cut
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ use Mojo::Base 'Mojolicious::Controller';
|
|||
|
||||
use Koha::ItemTypes;
|
||||
|
||||
use Try::Tiny;
|
||||
use Try::Tiny qw(catch try);
|
||||
|
||||
=head1 API
|
||||
|
||||
|
@ -35,14 +35,12 @@ sub list {
|
|||
my $c = shift->openapi->valid_input or return;
|
||||
|
||||
return try {
|
||||
my $itemtypes_set = Koha::ItemTypes->new;
|
||||
my $itemtypes = $c->objects->search( $itemtypes_set );
|
||||
my $item_types = $c->objects->search( Koha::ItemTypes->new );
|
||||
|
||||
return $c->render( status => 200, openapi => $itemtypes );
|
||||
return $c->render( status => 200, openapi => $item_types );
|
||||
} catch {
|
||||
$c->unhandled_exception($_);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
type: object
|
||||
properties:
|
||||
item_type:
|
||||
item_type_id:
|
||||
type: string
|
||||
description: Unique key, a code associated with the item type
|
||||
readOnly: true
|
||||
|
@ -93,4 +93,4 @@ properties:
|
|||
|
||||
additionalProperties: false
|
||||
required:
|
||||
- item_type
|
||||
- item_type_id
|
||||
|
|
|
@ -32,7 +32,7 @@ my $builder = t::lib::TestBuilder->new;
|
|||
my $t = Test::Mojo->new('Koha::REST::V1');
|
||||
t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
|
||||
|
||||
subtest 'list_item_types() tests' => sub {
|
||||
subtest 'list() tests' => sub {
|
||||
|
||||
plan tests => 12;
|
||||
|
||||
|
@ -109,11 +109,10 @@ subtest 'list_item_types() tests' => sub {
|
|||
my $unauth_userid = $patron->userid;
|
||||
|
||||
## Authorized user tests
|
||||
# No category, 404 expected
|
||||
$t->get_ok("//$userid:$password@/api/v1/item_types")->status_is(200)->json_has('/0');
|
||||
|
||||
for my $json ( @{ $t->tx->res->json } ) {
|
||||
if ( $json->{item_type} eq 'TEST_IT' ) {
|
||||
if ( $json->{item_type_id} eq 'TEST_IT' ) {
|
||||
is( $json->{description}, 'Test item type' );
|
||||
ok( !exists $json->{translated_descriptions} );
|
||||
}
|
||||
|
@ -123,7 +122,7 @@ subtest 'list_item_types() tests' => sub {
|
|||
->status_is(200)->json_has('/0');
|
||||
|
||||
for my $json ( @{ $t->tx->res->json } ) {
|
||||
if ( $json->{item_type} eq 'TEST_IT' ) {
|
||||
if ( $json->{item_type_id} eq 'TEST_IT' ) {
|
||||
is( $json->{description}, 'Test item type' );
|
||||
is_deeply(
|
||||
$json->{translated_descriptions},
|
||||
|
|
Loading…
Reference in a new issue