From e61b65437d06e6282049f1b0647fd235bb6ee152 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 16 Aug 2024 11:01:31 +0000 Subject: [PATCH] Bug 35287: (QA follow-up): Squash Remove leftover unused code Add missing pod Tidy Run: qa -c 11 -v 2 Verify everything is green --- Koha/Object/Mixin/AdditionalFields.pm | 4 +-- Koha/Objects/Mixin/AdditionalFields.pm | 16 ++++++---- Koha/REST/V1/ERM/Licenses.pm | 14 +++++---- .../Koha/Object/Mixin/AdditionalFields.t | 30 +++++++++---------- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/Koha/Object/Mixin/AdditionalFields.pm b/Koha/Object/Mixin/AdditionalFields.pm index 18e5c5efc7..a27f6f89ea 100644 --- a/Koha/Object/Mixin/AdditionalFields.pm +++ b/Koha/Object/Mixin/AdditionalFields.pm @@ -232,7 +232,7 @@ REST API embed of additional_field_values =cut sub extended_attributes { - my ($self, $extended_attributes) = @_; + my ( $self, $extended_attributes ) = @_; if ($extended_attributes) { $self->set_additional_fields($extended_attributes); @@ -297,7 +297,7 @@ sub strings_map { ); } - my @sorted = sort { $a->{field_id} <=> $b->{field_id} } @{ $strings->{additional_field_values} }; + my @sorted = sort { $a->{field_id} <=> $b->{field_id} } @{ $strings->{additional_field_values} }; my @non_empty = grep { $_->{value_str} ne "" } @sorted; $strings->{additional_field_values} = \@non_empty; diff --git a/Koha/Objects/Mixin/AdditionalFields.pm b/Koha/Objects/Mixin/AdditionalFields.pm index 8351aba549..1fe79af4a5 100644 --- a/Koha/Objects/Mixin/AdditionalFields.pm +++ b/Koha/Objects/Mixin/AdditionalFields.pm @@ -60,20 +60,26 @@ sub filter_by_additional_fields { =head3 extended_attributes_config + Returns a hash containing the configuration for extended attributes + =cut sub extended_attributes_config { my ($self) = @_; - my $tablename_query = $self->extended_attributes_tablename_query; - return { - 'id_field' => { 'foreign' => 'record_id', 'self' => $self->_resultset->result_source->primary_columns }, - 'key_field' => 'field_id', - 'schema_class' => 'Koha::Schema::Result::AdditionalFieldValue', + 'id_field' => { 'foreign' => 'record_id', 'self' => $self->_resultset->result_source->primary_columns }, + 'key_field' => 'field_id', + 'schema_class' => 'Koha::Schema::Result::AdditionalFieldValue', }; } +=head3 extended_attributes_tablename_query + + Returns a hash containing the tablename and operator for extended attributes. + +=cut + sub extended_attributes_tablename_query { my ($self) = @_; diff --git a/Koha/REST/V1/ERM/Licenses.pm b/Koha/REST/V1/ERM/Licenses.pm index 1a233761ee..ccee789686 100644 --- a/Koha/REST/V1/ERM/Licenses.pm +++ b/Koha/REST/V1/ERM/Licenses.pm @@ -85,15 +85,16 @@ sub add { my $body = $c->req->json; - my $user_roles = delete $body->{user_roles} // []; - my $documents = delete $body->{documents} // []; + my $user_roles = delete $body->{user_roles} // []; + my $documents = delete $body->{documents} // []; my $extended_attributes = delete $body->{extended_attributes} // []; my $license = Koha::ERM::License->new_from_api($body)->store; $license->user_roles($user_roles); $license->documents($documents); - my @extended_attributes = map { {'id' => $_->{field_id}, 'value' => $_->{value}} } @{$extended_attributes}; + my @extended_attributes = + map { { 'id' => $_->{field_id}, 'value' => $_->{value} } } @{$extended_attributes}; $license->extended_attributes( \@extended_attributes ); $c->res->headers->location($c->req->url->to_string . '/' . $license->license_id); @@ -167,15 +168,16 @@ sub update { my $body = $c->req->json; - my $user_roles = delete $body->{user_roles} // []; - my $documents = delete $body->{documents} // []; + my $user_roles = delete $body->{user_roles} // []; + my $documents = delete $body->{documents} // []; my $extended_attributes = delete $body->{extended_attributes} // []; $license->set_from_api($body)->store; $license->user_roles($user_roles); $license->documents($documents); - my @extended_attributes = map { {'id' => $_->{field_id}, 'value' => $_->{value}} } @{$extended_attributes}; + my @extended_attributes = + map { { 'id' => $_->{field_id}, 'value' => $_->{value} } } @{$extended_attributes}; $license->extended_attributes( \@extended_attributes ); $c->res->headers->location($c->req->url->to_string . '/' . $license->license_id); diff --git a/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t b/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t index a9dae708d3..2b801e19c1 100755 --- a/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t +++ b/t/db_dependent/Koha/Object/Mixin/AdditionalFields.t @@ -285,9 +285,9 @@ subtest 'prepare_cgi_additional_field_values' => sub { subtest 'strings_map() tests' => sub { plan tests => 1; - $schema->txn_begin; - Koha::AdditionalFields->search->delete; - my $license = Koha::ERM::License->new( + $schema->txn_begin; + Koha::AdditionalFields->search->delete; + my $license = Koha::ERM::License->new( { name => "license name", type => "national", @@ -296,7 +296,7 @@ subtest 'strings_map() tests' => sub { } ); $license->store()->discard_changes(); - my $field = Koha::AdditionalField->new( + my $field = Koha::AdditionalField->new( { tablename => 'erm_licenses', name => 'af_1', @@ -304,7 +304,7 @@ subtest 'strings_map() tests' => sub { } ); $field->store()->discard_changes(); - my $field2 = Koha::AdditionalField->new( + my $field2 = Koha::AdditionalField->new( { tablename => 'erm_licenses', name => 'af_2', @@ -312,7 +312,7 @@ subtest 'strings_map() tests' => sub { } ); $field2->store()->discard_changes(); - my $value = 'some license value'; + my $value = 'some license value'; $license->set_additional_fields( [ { @@ -327,23 +327,23 @@ subtest 'strings_map() tests' => sub { } ] ); - $license->add_additional_fields( + $license->add_additional_fields( { $field2->id => ['second field'], }, 'erm_licenses' ); - my $av_category = Koha::AuthorisedValueCategory->new( { category_name => "AV_CAT_NAME" } ); + my $av_category = Koha::AuthorisedValueCategory->new( { category_name => "AV_CAT_NAME" } ); $av_category->store()->discard_changes(); - my $av_value = Koha::AuthorisedValue->new( + my $av_value = Koha::AuthorisedValue->new( { category => $av_category->category_name, authorised_value => 'BOB', lib => "Robert" } ); - my $av_field = Koha::AdditionalField->new( + my $av_field = Koha::AdditionalField->new( { tablename => "erm_licenses", name => "av_field", @@ -352,15 +352,15 @@ subtest 'strings_map() tests' => sub { } ); $av_field->store()->discard_changes(); - $license->add_additional_fields( + $license->add_additional_fields( { $av_field->id => [ $av_value->authorised_value ], }, 'erm_licenses' ); - my $values = $license->get_additional_field_values_for_template; - my $strings_map = $license->strings_map; + my $values = $license->get_additional_field_values_for_template; + my $strings_map = $license->strings_map; is_deeply( $strings_map, { @@ -387,6 +387,6 @@ subtest 'strings_map() tests' => sub { }, 'strings_map looks good' ); - $schema->txn_rollback; - ; + $schema->txn_rollback; + }; -- 2.39.2