Bug 24543: Fix wrong test in api/v1/checkouts.t

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ä <joonas.kylmala@helsinki.fi>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2020-01-30 11:51:25 +01:00 committed by Martin Renvoize
parent fd1ade2a67
commit bc05a90aa7
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 8 additions and 8 deletions

View File

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