From 997f01511c78ae64b2b83f8652ff70f9af7ccbec 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 Removed redundant commented in AdditionalFields_spec.ts Run: qa -c 11 -v 2 Verify everything is green Sponsored-by: UKHSA - UK Health Security Agency Sponsored-by: PTFS Europe Ltd Signed-off-by: Paul Derscheid --- Koha/Object/Mixin/AdditionalFields.pm | 4 +-- Koha/Objects/Mixin/AdditionalFields.pm | 16 ++++++---- Koha/REST/V1/ERM/Licenses.pm | 14 +++++---- .../integration/AdditionalFields_spec.ts | 2 -- .../Koha/Object/Mixin/AdditionalFields.t | 30 +++++++++---------- 5 files changed, 36 insertions(+), 30 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/cypress/integration/AdditionalFields_spec.ts b/t/cypress/integration/AdditionalFields_spec.ts index 28ec967afb..9a7885aa5d 100644 --- a/t/cypress/integration/AdditionalFields_spec.ts +++ b/t/cypress/integration/AdditionalFields_spec.ts @@ -348,7 +348,6 @@ describe("Additional Fields operations", () => { statusCode: 200, } ).as("avcategories"); - // cy.wait("@avcategories"); cy.intercept("GET", "/api/v1/erm/licenses/*", license).as( "get-license" @@ -453,7 +452,6 @@ describe("Additional Fields operations", () => { statusCode: 200, } ).as("avcategories"); - // cy.wait("@avcategories"); // There are additional fields, fieldset should exist cy.visit("/cgi-bin/koha/erm/licenses/add"); cy.get("#licenses_add form #additional_fields").should("exist"); 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.47.0