Bug 41889: [Rmaint] Remove incorrectly added test
This commit is contained in:
parent
90a43b0dd1
commit
58badaa148
|
|
@ -602,113 +602,6 @@ subtest 'add checkout' => sub {
|
|||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'renew with fine override (x-koha-override: debt_limit)' => sub {
|
||||
plan tests => 15;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
# Create a librarian with circulate permission
|
||||
my $librarian = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Patrons',
|
||||
value => { flags => 2 } # Superlibrarian
|
||||
}
|
||||
);
|
||||
my $password = 'thePassword123';
|
||||
$librarian->set_password( { password => $password, skip_validation => 1 } );
|
||||
my $userid = $librarian->userid;
|
||||
|
||||
# Create a regular patron
|
||||
my $patron = $builder->build_object(
|
||||
{
|
||||
class => 'Koha::Patrons',
|
||||
value => { flags => 0 }
|
||||
}
|
||||
);
|
||||
|
||||
# Create a branch and set up userenv
|
||||
my $branch = $builder->build( { source => 'Branch' } );
|
||||
t::lib::Mocks::mock_userenv(
|
||||
{ branchcode => $branch->{branchcode}, borrowernumber => $librarian->borrowernumber } );
|
||||
|
||||
# Set up circulation rules
|
||||
Koha::CirculationRules->set_rules(
|
||||
{
|
||||
categorycode => undef,
|
||||
itemtype => undef,
|
||||
branchcode => undef,
|
||||
rules => {
|
||||
renewalperiod => 7,
|
||||
renewalsallowed => 10,
|
||||
issuelength => 5,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
my $item = $builder->build_sample_item;
|
||||
|
||||
# Check out the item
|
||||
my $checkout = AddIssue( $patron, $item->barcode );
|
||||
|
||||
# Set FineNoRenewals to a low amount
|
||||
t::lib::Mocks::mock_preference( 'FineNoRenewals', 5 );
|
||||
|
||||
# Add a fine that exceeds the limit
|
||||
my $account = Koha::Account->new( { patron_id => $patron->borrowernumber } );
|
||||
$account->add_debit(
|
||||
{
|
||||
amount => 10.00,
|
||||
type => 'OVERDUE',
|
||||
interface => 'test',
|
||||
description => 'Test fine',
|
||||
item_id => $item->itemnumber,
|
||||
}
|
||||
);
|
||||
|
||||
my $checkout_id = $checkout->id;
|
||||
|
||||
# Test 1: Renewal should be blocked due to excessive fines
|
||||
$t->post_ok("//$userid:$password@/api/v1/checkouts/$checkout_id/renewal")
|
||||
->status_is(403)
|
||||
->json_like( '/error' => qr/too_much_owing/ );
|
||||
|
||||
# Test 2: Override should fail when AllowFineOverrideRenewing is disabled
|
||||
t::lib::Mocks::mock_preference( 'AllowFineOverrideRenewing', 0 );
|
||||
|
||||
$t->post_ok( "//$userid:$password@/api/v1/checkouts/$checkout_id/renewal" => { 'x-koha-override' => 'debt_limit' } )
|
||||
->status_is(403)
|
||||
->json_like( '/error' => qr/too_much_owing/ );
|
||||
|
||||
# Test 3: Override should succeed when AllowFineOverrideRenewing is enabled
|
||||
t::lib::Mocks::mock_preference( 'AllowFineOverrideRenewing', 1 );
|
||||
|
||||
$t->post_ok( "//$userid:$password@/api/v1/checkouts/$checkout_id/renewal" => { 'x-koha-override' => 'debt_limit' } )
|
||||
->status_is(201)
|
||||
->json_has('/due_date');
|
||||
|
||||
# Refresh checkout
|
||||
$checkout = Koha::Checkouts->find($checkout_id);
|
||||
|
||||
# Test 4: Test with /renewals endpoint (alternative endpoint)
|
||||
# Add another checkout to test the other endpoint
|
||||
my $item2 = $builder->build_sample_item;
|
||||
my $checkout2 = AddIssue( $patron, $item2->barcode );
|
||||
my $checkout2_id = $checkout2->id;
|
||||
|
||||
# Should be blocked without override
|
||||
$t->post_ok("//$userid:$password@/api/v1/checkouts/$checkout2_id/renewals")
|
||||
->status_is(403)
|
||||
->json_like( '/error' => qr/too_much_owing/ );
|
||||
|
||||
# Should succeed with override
|
||||
$t->post_ok(
|
||||
"//$userid:$password@/api/v1/checkouts/$checkout2_id/renewals" => { 'x-koha-override' => 'debt_limit' } )
|
||||
->status_is(201)
|
||||
->json_has('/due_date');
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'list checkouts that have been checked in and the patron has been deleted' => sub {
|
||||
plan tests => 6;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue