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 <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>
This commit is contained in:
Nick Clemens 2019-04-02 00:34:43 +00:00
parent f6bc67e851
commit a5fcd93f72
2 changed files with 18 additions and 5 deletions

View file

@ -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,

View 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