From 7eb177eb79b409789f3dcfaefce252804b5e56d9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 6 Nov 2024 11:57:42 +0100 Subject: [PATCH] Bug 34068: Fix tests Several wrong things in the previous attempt: * as_list returns an array * as_list returns objects, ->{library_id} does not exist * as_list does not returns api object, you need to call ->branchcode to get the id * $pickup_locations defined for both situations was confusing Signed-off-by: David Nind Signed-off-by: Pedro Amorim --- Koha/REST/V1/Holds.pm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm index c703aba0b53..121e68313e4 100644 --- a/Koha/REST/V1/Holds.pm +++ b/Koha/REST/V1/Holds.pm @@ -462,20 +462,18 @@ sub pickup_locations { $ps_set = $hold->biblio->pickup_locations( { patron => $hold->patron } ); } - my $pickup_locations; my @response = (); if ( C4::Context->preference('AllowHoldPolicyOverride') ) { - $pickup_locations = $ps_set->as_list; my $libraries_rs = Koha::Libraries->search( { pickup_location => 1 } ); my $libraries = $c->objects->search($libraries_rs); @response = map { my $library = $_; $library->{needs_override} = ( - any { $_->{library_id} eq $library->{library_id} } - @{$pickup_locations} + any { $_->branchcode eq $library->{library_id} } + $ps_set->as_list ) ? Mojo::JSON->false : Mojo::JSON->true; @@ -488,7 +486,7 @@ sub pickup_locations { ); } - $pickup_locations = $c->objects->search( $ps_set ); + my $pickup_locations = $c->objects->search( $ps_set ); @response = map { $_->{needs_override} = Mojo::JSON->false; $_; } @{$pickup_locations}; return $c->render( -- 2.39.5