From f23f731de281eb08c8121e0b8b85b2018042c9b8 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 Signed-off-by: David Nind Signed-off-by: Tomas Cohen Arazi Edit: amended to get rid of tidy errors Signed-off-by: Katrin Fischer --- .../api/v1/extended_attribute_types.t | 19 ++++++++++++++++++- 1 file changed, 18 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..eacb138154 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,23 @@ 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.5