From 7c161a639fb8c69385abbc060df5be21e25095d3 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 30 Jan 2020 11:51:25 +0100 Subject: [PATCH] Bug 24543: Fix wrong test in api/v1/checkouts.t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In t/db_dependent/api/v1/checkouts.t we define a circulation rule with renewalperiod=7. But then the expected due date is today+14 days. However, at the beginning of the script, the due_date of the issue is today+14 days. That highlight that the renewal period is not taken into account. The circulation rule is created with renewalperiod and renewalsallowed, however GetLoanLength check the existence of issuelength to return the rule. GetLoanLength finally return the default rule, with renewalperiod=0 Note that this has been found working on bug 18936, code will be cleaned on that patchset. Test plan: % prove t/db_dependent/api/v1/checkouts.t must return green before and after this patch Signed-off-by: Joonas Kylmälä Signed-off-by: Martin Renvoize --- t/db_dependent/api/v1/checkouts.t | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/t/db_dependent/api/v1/checkouts.t b/t/db_dependent/api/v1/checkouts.t index 5a3447412e..3a5c5deab9 100644 --- a/t/db_dependent/api/v1/checkouts.t +++ b/t/db_dependent/api/v1/checkouts.t @@ -71,6 +71,12 @@ $t->get_ok( "//$userid:$password@/api/v1/checkouts?patron_id=$notexisting_patron ->status_is(200) ->json_is([]); +$dbh->do('DELETE FROM issuingrules'); +$dbh->do(q{ + INSERT INTO issuingrules (categorycode, branchcode, itemtype, renewalperiod, renewalsallowed, issuelength) + VALUES (?, ?, ?, ?, ?, ?) +}, {}, '*', '*', '*', 7, 1, 5); + my $item1 = $builder->build_sample_item; my $item2 = $builder->build_sample_item; my $item3 = $builder->build_sample_item; @@ -168,15 +174,9 @@ $t->get_ok( "//$userid:$password@/api/v1/checkouts/" . $issue2->issue_id) ->json_is('/due_date' => output_pref( { dateformat => "rfc3339", dt => $date_due2 }) ); -$dbh->do('DELETE FROM issuingrules'); -$dbh->do(q{ - INSERT INTO issuingrules (categorycode, branchcode, itemtype, renewalperiod, renewalsallowed) - VALUES (?, ?, ?, ?, ?) -}, {}, '*', '*', '*', 7, 1); - -my $expected_datedue = DateTime->now +my $expected_datedue = $date_due ->set_time_zone('local') - ->add(days => 14) + ->add(days => 7) ->set(hour => 23, minute => 59, second => 0); $t->post_ok ( "//$userid:$password@/api/v1/checkouts/" . $issue1->issue_id . "/renewal" ) ->status_is(201) -- 2.20.1