From 058f79aaba6b6c29dc1ce3802693c2194fc23e62 Mon Sep 17 00:00:00 2001
From: Nick Clemens <nick@bywatersolutions.com>
Date: Thu, 22 Apr 2021 15:22:49 +0000
Subject: [PATCH] Bug 16787: (follow-up) Add and adjust ILSDI tests

---
 t/db_dependent/ILSDI_Services.t | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t
index 37fd3fbdfb..c3be5cea94 100755
--- a/t/db_dependent/ILSDI_Services.t
+++ b/t/db_dependent/ILSDI_Services.t
@@ -300,7 +300,7 @@ subtest 'LookupPatron test' => sub {
 
 subtest 'Holds test' => sub {
 
-    plan tests => 8;
+    plan tests => 9;
 
     $schema->storage->txn_begin;
 
@@ -359,7 +359,7 @@ subtest 'Holds test' => sub {
             itemtype     => $item2->{itype},
             branchcode   => $patron->{branchcode},
             rule_name    => 'reservesallowed',
-            rule_value   => 0,
+            rule_value   => 1,
         }
     );
 
@@ -371,6 +371,24 @@ subtest 'Holds test' => sub {
     $reply = C4::ILSDI::Services::HoldItem( $query );
     is( $reply->{code}, 'tooManyReserves', "Too many reserves" );
 
+    Koha::CirculationRules->set_rule(
+        {
+            categorycode => $patron->{categorycode},
+            itemtype     => $item2->{itype},
+            branchcode   => $patron->{branchcode},
+            rule_name    => 'reservesallowed',
+            rule_value   => 0,
+        }
+    );
+
+    $query = CGI->new;
+    $query->param( 'patron_id', $patron->{borrowernumber});
+    $query->param( 'bib_id', $item2->biblionumber);
+    $query->param( 'item_id', $item2->itemnumber);
+
+    $reply = C4::ILSDI::Services::HoldItem( $query );
+    is( $reply->{code}, 'noReservesAllowed', "No reserves allowed" );
+
     my $origin_branch = $builder->build(
         {
             source => 'Branch',
-- 
2.11.0