Bug 18936: (follow-up) Fix checkouts endpoint and its tests
- Fixes a bug caused by the refactoring in Koha/REST/V1/Checkouts.pm (run the tests without this patch and you will see the tests fails because 'rule_name' parameter was forgotten). - Changes the tests to use the new Koha::CirculationRule objects instead of directly using issuingrules DB table 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>
This commit is contained in:
parent
d3d6df99b8
commit
8fd9ff1730
|
|
@ -213,13 +213,14 @@ sub allows_renewal {
|
|||
categorycode => $checkout->patron->categorycode,
|
||||
itemtype => $checkout->item->effective_itemtype,
|
||||
branchcode => $checkout->branchcode,
|
||||
rule_name => 'renewalsallowed',
|
||||
}
|
||||
);
|
||||
return $c->render(
|
||||
status => 200,
|
||||
openapi => {
|
||||
allows_renewal => $renewable,
|
||||
max_renewals => $rule->renewalsallowed,
|
||||
max_renewals => $rule->rule_value,
|
||||
current_renewals => $checkout->renewals,
|
||||
error => $error
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,11 +71,18 @@ $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);
|
||||
Koha::CirculationRules->set_rules(
|
||||
{
|
||||
categorycode => undef,
|
||||
itemtype => undef,
|
||||
branchcode => undef,
|
||||
rules => {
|
||||
renewalperiod => 7,
|
||||
renewalsallowed => 1,
|
||||
issuelength => 5,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
my $item1 = $builder->build_sample_item;
|
||||
my $item2 = $builder->build_sample_item;
|
||||
|
|
@ -173,7 +180,6 @@ $t->get_ok( "//$userid:$password@/api/v1/checkouts/" . $issue2->issue_id)
|
|||
->status_is(200)
|
||||
->json_is('/due_date' => output_pref( { dateformat => "rfc3339", dt => $date_due2 }) );
|
||||
|
||||
|
||||
my $expected_datedue = $date_due
|
||||
->set_time_zone('local')
|
||||
->add(days => 7)
|
||||
|
|
|
|||
Loading…
Reference in New Issue