From 584953209c07cf98d339ec620ce521cbbc6cef2e Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 2 Apr 2019 00:34:43 +0000 Subject: [PATCH] Bug 22619: Fix null empty behaviour for new rules To test: 1 - Go to Admin->Circulation and fines rules 2 - Set All/All rules ot have a limit for Current checkouts allowed (and onsite checkouts allowed) 3 - Select an itemtype to add a new rule 4 - Save without entering any values 5 - Note that new rule displays with the same numebr as the all/all rule 6 - Check the DB, not no lines were added to circulation_rules table 7 - Delete the rule from the staff client 8 - Apply patch 9 - Repeat, note the new rule is unlimited 10 - Run selenium tests 11 - They pass! 12 - Check no rules/itemtypes are added to your system by the tests Signed-off-by: Liz Rea Signed-off-by: Katrin Fischer Verified that the patch works, but failed to got the Selenium tests to pass before and after applying the patch. Leaving that to the next tester. --- admin/smart-rules.pl | 5 ++--- t/db_dependent/selenium/administration_tasks.t | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index e9c1bf121d..d248f4ae48 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -164,9 +164,9 @@ elsif ($op eq 'add') { $holds_per_day = undef if $holds_per_day !~ /^\d+/; my $onshelfholds = $input->param('onshelfholds') || 0; $maxissueqty =~ s/\s//g; - $maxissueqty = undef if $maxissueqty !~ /^\d+/; + $maxissueqty = '' if $maxissueqty !~ /^\d+/; $maxonsiteissueqty =~ s/\s//g; - $maxonsiteissueqty = undef if $maxonsiteissueqty !~ /^\d+/; + $maxonsiteissueqty = '' if $maxonsiteissueqty !~ /^\d+/; my $issuelength = $input->param('issuelength'); $issuelength = $issuelength eq q{} ? undef : $issuelength; my $lengthunit = $input->param('lengthunit'); @@ -221,7 +221,6 @@ elsif ($op eq 'add') { } else { Koha::IssuingRule->new()->set($params)->store(); } - Koha::CirculationRules->set_rules( { categorycode => $bor, diff --git a/t/db_dependent/selenium/administration_tasks.t b/t/db_dependent/selenium/administration_tasks.t index 7ecdfbf689..69145ad7fb 100644 --- a/t/db_dependent/selenium/administration_tasks.t +++ b/t/db_dependent/selenium/administration_tasks.t @@ -23,9 +23,12 @@ use Modern::Perl; use C4::Context; -use Test::More tests => 1; +use Test::More tests => 3; use t::lib::Selenium; +use t::lib::TestBuilder; + +my $builder = t::lib::TestBuilder->new; my $login = $ENV{KOHA_USER} || 'koha'; @@ -67,12 +70,23 @@ SKIP: { }; { # Circulation/fine rules + my $itype = $builder->build_object({ class => "Koha::ItemTypes" }); $driver->get($mainpage); $s->click( { href => '/admin/admin-home.pl', main => 'container-main' } ) ; # Koha administration $s->click( { href => '/admin/smart-rules.pl', main_class => 'main container-fluid' } ) ; # Circulation and fines rules - # TODO Create smart navigation here + my $elt = $driver->find_element('//tr[@id="edit_row"]/td/select[@id="matrixitemtype"]/option[@value="'.$itype->itemtype.'"]'); + is( $elt->get_text(),$itype->description,"Our new itemtype is in the list"); + $elt->click(); + $elt = $driver->find_element('//tr[@id="edit_row"]/td[@class="actions"]/button[@type="submit"]'); + $elt->click(); + $elt = $driver->find_elements('//table[@id="default-circulation-rules"]/tbody/tr/td[contains(text(),"'.$itype->description.'")]/following-sibling::td/span[text() = "Unlimited"]'); + is( @$elt,2,"We have unlimited checkouts"); + #Clean up + Koha::IssuingRules->find({itemtype=>$itype->itemtype})->delete(); + $itype->delete; + # TODO Create more smart rules navigation here }; { # Biblio frameworks -- 2.11.0