Bugzilla – Attachment 110715 Details for
Bug 26529
Holds rules enforced incorrectly when not set at library level
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26529: Define some rules as not able to be blank
Bug-26529-Define-some-rules-as-not-able-to-be-blan.patch (text/plain), 3.92 KB, created by
Andrew Fuerste-Henry
on 2020-09-24 22:42:19 UTC
(
hide
)
Description:
Bug 26529: Define some rules as not able to be blank
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2020-09-24 22:42:19 UTC
Size:
3.92 KB
patch
obsolete
>From 90609bba84e7fe140932a79620045ccbafdf9778 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 24 Sep 2020 18:21:45 +0000 >Subject: [PATCH] Bug 26529: Define some rules as not able to be blank > >This patch uses the existing hash that controls the scope of rules and adds a >new parameter 'can_be_blank' > >To test: >1 - Goto to Admin -> Circulation and fines rules and select a library >2 - Under "Default checkout, hold, and return policy" set: > Total current checkouts allowed: 1 > Hold policy: Not set > Hold pickup library match: Not set > Return policay: Not set >3 - Save the rule >4 - Check the DB > SELECT * FROM circulation_rules WHERE branchcode = 'BRANCHCODE' > using the branchcode for the library you chode >5 - Note holdallowed, returnbranch, and hold_fulfillment_policy rules exist with blank value >6 - Apply patch and restart all the things >7 - Reload the page and save the rules as before >8 - Check the DB and note the rules no longer exist >9 - pr0ve -v t/db_dependent/Koha/CirculationRules.t > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >--- > Koha/CirculationRules.pm | 5 +++++ > t/db_dependent/Koha/CirculationRules.t | 27 ++++++++++++++++++++++++++- > 2 files changed, 31 insertions(+), 1 deletion(-) > >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index 87062f541a..5b63998a8b 100644 >--- a/Koha/CirculationRules.pm >+++ b/Koha/CirculationRules.pm >@@ -62,12 +62,15 @@ our $RULE_KINDS = { > > holdallowed => { > scope => [ 'branchcode', 'itemtype' ], >+ can_be_blank => 0, > }, > hold_fulfillment_policy => { > scope => [ 'branchcode', 'itemtype' ], >+ can_be_blank => 0, > }, > returnbranch => { > scope => [ 'branchcode', 'itemtype' ], >+ can_be_blank => 0, > }, > > article_requests => { >@@ -278,6 +281,8 @@ sub set_rule { > my $itemtype = $params->{itemtype}; > my $rule_name = $params->{rule_name}; > my $rule_value = $params->{rule_value}; >+ my $can_be_blank = defined $kind_info->{can_be_blank} ? $kind_info->{can_be_blank} : 1; >+ $rule_value = undef if $rule_value eq "" && !$can_be_blank; > > for my $v ( $branchcode, $categorycode, $itemtype ) { > $v = undef if $v and $v eq '*'; >diff --git a/t/db_dependent/Koha/CirculationRules.t b/t/db_dependent/Koha/CirculationRules.t >index 708168a048..cc5468e7eb 100755 >--- a/t/db_dependent/Koha/CirculationRules.t >+++ b/t/db_dependent/Koha/CirculationRules.t >@@ -33,7 +33,7 @@ my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; > > subtest 'set_rule + get_effective_rule' => sub { >- plan tests => 8; >+ plan tests => 9; > > $schema->storage->txn_begin; > >@@ -102,6 +102,31 @@ subtest 'set_rule + get_effective_rule' => sub { > is( $rule->rule_value, 1, > 'Default rule is returned if there is no rule for this branchcode' ); > >+ subtest 'test rules that cannot be blank' => sub { >+ plan tests => 3; >+ foreach my $no_blank_rule ( ('holdallowed','hold_fulfillment_policy','returnbranch') ){ >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => $branchcode, >+ itemtype => '*', >+ rule_name => $no_blank_rule, >+ rule_value => '', >+ } >+ ); >+ >+ $rule = Koha::CirculationRules->get_effective_rule( >+ { >+ branchcode => $branchcode, >+ categorycode => undef, >+ itemtype => undef, >+ rule_name => $no_blank_rule, >+ } >+ ); >+ is( $rule, undef, 'Rules that cannot be blank are not set when passed blank string' ); >+ } >+ }; >+ >+ > subtest 'test rule matching with different combinations of rule scopes' => sub { > my ( $tests, $order ) = prepare_tests_for_rule_scope_combinations( > { >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26529
:
110686
|
110687
|
110695
|
110714
|
110715
|
110856
|
110857
|
110859
|
111251
|
111252
|
111253
|
111382
|
111471
|
111511