Bug 22619: Fix null empty behaviour for new rules
authorNick Clemens <nick@bywatersolutions.com>
Tue, 2 Apr 2019 00:34:43 +0000 (00:34 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Sat, 23 Mar 2019 08:32:03 +0000 (08:32 +0000)
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 <wizzyrea@gmail.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

admin/smart-rules.pl
t/db_dependent/selenium/administration_tasks.t

index e9c1bf1..d248f4a 100755 (executable)
@@ -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,
index 7ecdfbf..69145ad 100644 (file)
@@ -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