From 10418778751f5dbe7b45cbcb929b70f04ecdcc76 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 5 Jul 2024 12:04:17 +0000 Subject: [PATCH] Bug 37261: Add tests for returning unmapped tablename Test plan: 1) Apply this patch only, run tests: prove t/db_dependent/api/v1/extended_attribute_types.t 2) Notice they fail 3) Apply the fix patch, run tests again --- .../api/v1/extended_attribute_types.t | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/api/v1/extended_attribute_types.t b/t/db_dependent/api/v1/extended_attribute_types.t index 38e62ffd6f..2b1ccf4208 100755 --- a/t/db_dependent/api/v1/extended_attribute_types.t +++ b/t/db_dependent/api/v1/extended_attribute_types.t @@ -34,7 +34,7 @@ t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); subtest 'list() tests' => sub { - plan tests => 17; + plan tests => 20; $schema->storage->txn_begin; @@ -98,6 +98,24 @@ subtest 'list() tests' => sub { ] ); + my $additional_field_yet_another_different_tablename = $builder->build_object( + { + class => 'Koha::AdditionalFields', + value => { tablename => 'subscription', name => 'fourth_af_name' }, + } + ); + + # Four additional fields created, they should both be returned + $t->get_ok("//$userid:$password@/api/v1/extended_attribute_types") + ->status_is(200)->json_is( + [ + $additional_field->to_api, + $another_additional_field->to_api, + $additional_field_different_tablename->to_api, + $additional_field_yet_another_different_tablename->to_api, + ] + ); + # Filtering works, two existing additional fields returned for the queried table name $t->get_ok("//$userid:$password@/api/v1/extended_attribute_types?resource_type=invoice")->status_is(200) ->json_is( [ $additional_field->to_api, $another_additional_field->to_api ] ); -- 2.39.2