Bugzilla – Attachment 120047 Details for
Bug 24154
No indication that Default checkout, hold and return policy are set if values are blank
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24154: (follow-up) Make parameter and variable more explicit, add tests
Bug-24154-follow-up-Make-parameter-and-variable-mo.patch (text/plain), 8.14 KB, created by
Nick Clemens
on 2021-04-23 10:35:38 UTC
(
hide
)
Description:
Bug 24154: (follow-up) Make parameter and variable more explicit, add tests
Filename:
MIME Type:
Creator:
Nick Clemens
Created:
2021-04-23 10:35:38 UTC
Size:
8.14 KB
patch
obsolete
>From 7adcdafd5113fbd9799d47ff2d98c259a0445262 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 23 Apr 2021 10:34:06 +0000 >Subject: [PATCH] Bug 24154: (follow-up) Make parameter and variable more > explicit, add tests > >--- > Koha/Template/Plugin/CirculationRules.pm | 4 +- > .../prog/en/modules/admin/smart-rules.tt | 18 ++--- > t/db_dependent/Template/Plugin/CirculationRules.t | 93 ++++++++++++++++++++++ > 3 files changed, 104 insertions(+), 11 deletions(-) > create mode 100755 t/db_dependent/Template/Plugin/CirculationRules.t > >diff --git a/Koha/Template/Plugin/CirculationRules.pm b/Koha/Template/Plugin/CirculationRules.pm >index 0e39e908bc..7956bc8d80 100644 >--- a/Koha/Template/Plugin/CirculationRules.pm >+++ b/Koha/Template/Plugin/CirculationRules.pm >@@ -43,7 +43,7 @@ sub Get { > } > > sub Search { >- my ( $self, $branchcode, $categorycode, $itemtype, $rule_name, $want_rule) = @_; >+ my ( $self, $branchcode, $categorycode, $itemtype, $rule_name, $params) = @_; > > $branchcode = undef if $branchcode eq q{} or $branchcode eq q{*}; > $categorycode = undef if $categorycode eq q{} or $categorycode eq q{*}; >@@ -58,7 +58,7 @@ sub Search { > } > )->next; > >- return $rule if $want_rule; >+ return $rule if $params->{want_rule}; > return $rule->rule_value if $rule; > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >index d805ef208a..0557afa7d2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >@@ -543,16 +543,16 @@ > <th>Return policy</th> > <th class="noExport">Actions</th> > </tr> >- [% SET patron_maxissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxissueqty', 1, 1 ) %] >- [% SET patron_maxonsiteissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxonsiteissueqty', 1, 1 ) %] >- [% SET rule_value = CirculationRules.Search( current_branch, undef , undef, 'max_holds', 1, 1 ) %] >- [% SET holdallowed = CirculationRules.Search( current_branch, undef, undef, 'holdallowed', 1 ) %] >- [% SET hold_fulfillment_policy = CirculationRules.Search( current_branch, undef, undef, 'hold_fulfillment_policy', 1 ) %] >- [% SET returnbranch = CirculationRules.Search( current_branch, undef, undef, 'returnbranch', 1 ) %] >- [% SET dcharp = ( patron_maxissueqty || patron_maxonsiteissueqty || rule_value || holdallowed || hold_fulfillment_policy || returnbranch ) %] >+ [% SET patron_maxissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxissueqty', { want_rule = 1 } ) %] >+ [% SET patron_maxonsiteissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxonsiteissueqty', { want_rule = 1 } ) %] >+ [% SET rule_value = CirculationRules.Search( current_branch, undef , undef, 'max_holds', { want_rule = 1 } ) %] >+ [% SET holdallowed = CirculationRules.Search( current_branch, undef, undef, 'holdallowed', { want_rule = 1 } ) %] >+ [% SET hold_fulfillment_policy = CirculationRules.Search( current_branch, undef, undef, 'hold_fulfillment_policy', { want_rule = 1 }) %] >+ [% SET returnbranch = CirculationRules.Search( current_branch, undef, undef, 'returnbranch', { want_rule = 1 }) %] >+ [% SET default_checkout_hold_and_return_policy = ( patron_maxissueqty || patron_maxonsiteissueqty || rule_value || holdallowed || hold_fulfillment_policy || returnbranch ) %] > <tr> > <td> >- [% IF ( dcharp ) %] >+ [% IF ( default_checkout_hold_and_return_policy ) %] > <em> > Defaults > </em> >@@ -698,7 +698,7 @@ > </td> > <td class="actions"> > <button type="submit" class="btn btn-default btn-xs"><i class="fa fa-save"></i> Save</button> >- [% IF (dcharp) %] >+ [% IF ( default_checkout_hold_and_return_policy ) %] > <a class="btn btn-default btn-xs delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&categorycode=*&branch=[% current_branch | html %]" id="unset"><i class="fa fa-undo"></i> Unset</a> > [% END %] > </td> >diff --git a/t/db_dependent/Template/Plugin/CirculationRules.t b/t/db_dependent/Template/Plugin/CirculationRules.t >new file mode 100755 >index 0000000000..9b3f268a0d >--- /dev/null >+++ b/t/db_dependent/Template/Plugin/CirculationRules.t >@@ -0,0 +1,93 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 2; >+use Test::MockModule; >+ >+use Koha::CirculationRules; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+BEGIN { >+ use_ok('Koha::Template::Plugin::CirculationRules'); >+} >+ >+my $schema = Koha::Database->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'Basic function tests' => sub { >+ >+ plan tests => 10; >+ >+ $schema->storage->txn_begin; >+ >+ my $library_1 = $builder->build_object({ class => 'Koha::Libraries' }); >+ my $library_2 = $builder->build_object({ class => 'Koha::Libraries' }); >+ >+ my $plugin = Koha::Template::Plugin::CirculationRules->new(); >+ ok($plugin, "initialized CirculationRules plugin"); >+ >+ my $rule_value = $plugin->Get($library_1->branchcode,'*','*','maxholds'); >+ is($rule_value, undef, 'Max holds not set, Get returns undef'); >+ >+ $rule_value = $plugin->Search($library_1->branchcode,'*','*','maxholds'); >+ is($rule_value, undef, 'Max holds not set, Search returns undef'); >+ >+ my $rule = $plugin->Search($library_1->branchcode,'*','*','maxholds', { want_rule => 1 } ); >+ is($rule, undef, 'Max holds not set, Search with want_rule returns undef'); >+ >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => '*', >+ categorycode => '*', >+ rule_name => 'max_holds', >+ rule_value => 5, >+ } >+ ); >+ >+ Koha::CirculationRules->set_rule( >+ { >+ branchcode => $library_1->branchcode, >+ categorycode => '*', >+ rule_name => 'max_holds', >+ rule_value => "", >+ } >+ ); >+ >+ $rule_value = $plugin->Get($library_1->branchcode,'*','*','max_holds'); >+ is($rule_value, "", 'Max holds set to blank string (unlimited), Get returns blank string for branch'); >+ >+ $rule = $plugin->Search($library_1->branchcode,'*','*','max_holds', { want_rule => 1 } ); >+ is(ref $rule, "Koha::CirculationRule" , 'Max holds set to blank string, Search with want_rule returns a circulation rules object'); >+ is( $rule->rule_value, "",'Max holds set to blank string (unlimited), returned rule has correct value'); >+ >+ $rule_value = $plugin->Get($library_2->branchcode,'*','*','max_holds'); >+ is($rule_value, 5, 'Max holds default set to 5, Get returns 5 for branch with no rule set'); >+ >+ $rule_value = $plugin->Search('*','*','*','max_holds'); >+ is($rule_value, 5, 'Search for all libraries max holds rule, Search returns 5'); >+ >+ $rule_value = $plugin->Search($library_1->branchcode,'*','*','max_holds'); >+ is($rule_value, "", 'Max holds set to blank string (unlimited), Get returns blank string for branch'); >+ >+ >+ >+ $schema->storage->txn_rollback; >+}; >+ >-- >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 24154
:
119767
|
119950
|
120047
|
120561
|
120741
|
120742
|
120743