From 94c8e6e43cae75e902e09b2d4ed104390e08c939 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 3 May 2019 16:47:59 -0400 Subject: [PATCH] Bug 18928: (bug 22679 follow-up) Do not remove all rules along with the issuing rule We actually want to remove maxissueqty, maxonsiteissueqty and max_holds (for now) Signed-off-by: Agustin Moyano Signed-off-by: Liz Rea --- Koha/IssuingRule.pm | 5 +++++ t/db_dependent/Koha/IssuingRules.t | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Koha/IssuingRule.pm b/Koha/IssuingRule.pm index dd487299b1..cb9ac702c2 100644 --- a/Koha/IssuingRule.pm +++ b/Koha/IssuingRule.pm @@ -46,6 +46,11 @@ sub delete { branchcode => $branchcode, itemtype => $itemtype, categorycode => $categorycode, + rule_name => [qw( + maxissueqty + maxonsiteissueqty + max_holds + )], })->delete; $self->SUPER::delete; diff --git a/t/db_dependent/Koha/IssuingRules.t b/t/db_dependent/Koha/IssuingRules.t index 8dad888c23..90dd0a88b5 100644 --- a/t/db_dependent/Koha/IssuingRules.t +++ b/t/db_dependent/Koha/IssuingRules.t @@ -329,19 +329,28 @@ subtest 'delete' => sub { $builder->build_object({ class => 'Koha::CirculationRules', value => { categorycode => $category->categorycode, itemtype => $itemtype->itemtype, - branchcode => $library->branchcode + branchcode => $library->branchcode, + rule_name => 'maxissueqty', } }); $builder->build_object({ class => 'Koha::CirculationRules', value => { categorycode => $category->categorycode, itemtype => $itemtype->itemtype, - branchcode => $library->branchcode + branchcode => $library->branchcode, + rule_name => 'maxonsiteissueqty', + } + }); + $builder->build_object({ class => 'Koha::CirculationRules', value => { + categorycode => $category->categorycode, + itemtype => $itemtype->itemtype, + branchcode => $library->branchcode, + rule_name => 'another_rule', # That must not be deleted } }); # Now we delete the issuing rule $issue_rule->delete; - is( Koha::CirculationRules->search()->count ,$count, "We remove related circ rules with our issuing rule"); + is( Koha::CirculationRules->search()->count ,$count + 1, "We remove related circ rules maxissueqty and maxonsiteissueqty with our issuing rule"); }; -- 2.11.0