Bug 18936: (follow-up) Make sure we default to '*' if no rule exist
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 23 Jan 2020 13:45:36 +0000 (14:45 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 4 Feb 2020 09:56:28 +0000 (09:56 +0000)
Making sure the code is doing what we expect.
Also this patch fix CirculationRules.t

Signed-off-by: Minna Kivinen <minna.kivinen@hamk.fi>
Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

t/db_dependent/Koha/CirculationRules.t

index 2da5603..460868f 100644 (file)
@@ -33,12 +33,13 @@ $schema->storage->txn_begin;
 my $builder = t::lib::TestBuilder->new;
 
 subtest 'set_rule + get_effective_rule' => sub {
-    plan tests => 13;
+    plan tests => 14;
 
     my $categorycode = $builder->build_object( { class => 'Koha::Patron::Categories' } )->categorycode;
     my $itemtype     = $builder->build_object( { class => 'Koha::ItemTypes' } )->itemtype;
     my $branchcode   = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode;
-    my $rule_name    = 'my_rule';
+    my $branchcode_2 = $builder->build_object( { class => 'Koha::Libraries' } )->branchcode;
+    my $rule_name    = 'maxissueqty';
     my $default_rule_value = 1;
 
     my $rule;
@@ -109,6 +110,17 @@ subtest 'set_rule + get_effective_rule' => sub {
     is( $rule->rule_value, 2,
         'More specific rule is returned when itemtype is given' );
 
+    $rule = Koha::CirculationRules->get_effective_rule(
+        {
+            branchcode   => $branchcode_2,
+            categorycode => '*',
+            itemtype     => '*',
+            rule_name    => $rule_name,
+        }
+    );
+    is( $rule->rule_value, 1,
+        'Default rule is returned if there is no rule for this branchcode' );
+
     Koha::CirculationRules->set_rule(
         {
             branchcode   => '*',