Bug 18930: (RM follow-up) Restore primary key find

The find method in RefundLostItemFeeRules had been overloaded to only
support a hash being passed, however find can be called with a bare
array of primary key values (i.e. id in this case).  TestBuilder relies
on this functionality and started to fail; This patch simply restores
the original behaviour for when a single value (or array of values) is
passed.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2019-07-12 14:55:09 +01:00
parent d4d02fbe29
commit ce17dc90a1
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
4 changed files with 18 additions and 3 deletions

View File

@ -36,7 +36,7 @@ Koha::RefundLostItemFeeRules - Koha RefundLostItemFeeRules object set class
=cut
=head3 type
=head3 _type
=cut
@ -145,7 +145,9 @@ Inherit from Koha::Objects->find(), but forces rule_name => 'refund'
sub find {
my ( $self, @pars ) = @_;
$pars[0]->{rule_name} = 'refund';
if ( ref($pars[0]) eq 'HASH' ) {
$pars[0]->{rule_name} = 'refund';
}
return $self->SUPER::find(@pars);
}

View File

@ -180,6 +180,13 @@ __PACKAGE__->belongs_to(
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-05 14:29:17
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QHMqvrtX0ohJe70PHUYZ0Q
sub koha_objects_class {
'Koha::CirculationRules';
}
sub koha_object_class {
'Koha::CirculationRule';
}
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

View File

@ -374,7 +374,7 @@ subtest 'Koha::RefundLostItemFeeRules::should_refund() tests' => sub {
subtest 'Koha::RefundLostItemFeeRules::find() tests' => sub {
plan tests => 4;
plan tests => 5;
# Start transaction
$schema->storage->txn_begin;
@ -395,6 +395,9 @@ subtest 'Koha::RefundLostItemFeeRules::find() tests' => sub {
}
}
);
ok(defined Koha::RefundLostItemFeeRules->find($default_non_refund->{id}), 'Find should continue to work when passed an id');
my $specific_non_refund = $builder->build(
{
source => 'CirculationRule',

View File

@ -565,6 +565,9 @@ sub _gen_default_values {
AuthHeader => {
marcxml => '',
},
RefundLostItemFeeRules => {
rule_name => 'refund',
},
};
}