From d5ae4ad722435fbf71fa5db6cbf83ce3a83e6641 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 3 Nov 2025 10:43:44 +0000 Subject: [PATCH] Bug 40517: (QA follow-up): Fix tests Enforce no hold group when creating hold object When a hold is created by build_object, it's auto-assigned a hold_group_id (as expected). When a hold is ->fill, it's hold_group_id is cleared by cleanup_hold_group (as expected). The problem is then this causes the object before ->fill to be out of sync with the up to date object returned by the API (i.e. the latter has an empty hold_group_id, as expected, but the former has the auto-assigned hold_group_id). Using ->discard_changes or ->get_from_storage doesnt work because the became a after ->fill. --- t/db_dependent/api/v1/patrons_holds.t | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/api/v1/patrons_holds.t b/t/db_dependent/api/v1/patrons_holds.t index 67cd30b4d32..78f995488c6 100755 --- a/t/db_dependent/api/v1/patrons_holds.t +++ b/t/db_dependent/api/v1/patrons_holds.t @@ -53,9 +53,12 @@ subtest 'list() tests' => sub { $t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron->id . '/holds' )->status_is( 200, 'REST3.2.2' ) ->json_is( [] ); - my $hold_1 = $builder->build_object( { class => 'Koha::Holds', value => { borrowernumber => $patron->id } } ); - my $hold_2 = $builder->build_object( { class => 'Koha::Holds', value => { borrowernumber => $patron->id } } ); - my $hold_3 = $builder->build_object( { class => 'Koha::Holds', value => { borrowernumber => $patron->id } } ); + my $hold_1 = $builder->build_object( + { class => 'Koha::Holds', value => { hold_group_id => undef, borrowernumber => $patron->id } } ); + my $hold_2 = $builder->build_object( + { class => 'Koha::Holds', value => { hold_group_id => undef, borrowernumber => $patron->id } } ); + my $hold_3 = $builder->build_object( + { class => 'Koha::Holds', value => { hold_group_id => undef, borrowernumber => $patron->id } } ); $t->get_ok( "//$userid:$password@/api/v1/patrons/" . $patron->id . '/holds?_order_by=+me.hold_id' ) ->status_is( 200, 'REST3.2.2' ) -- 2.39.5