Bugzilla – Attachment 101421 Details for
Bug 24476
Allow patrons to opt-out of auto-renewal
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24476: Change CanBookBeRenewed and adjust tests
Bug-24476-Change-CanBookBeRenewed-and-adjust-tests.patch (text/plain), 4.96 KB, created by
Nick Clemens (kidclamp)
on 2020-03-23 11:57:58 UTC
(
hide
)
Description:
Bug 24476: Change CanBookBeRenewed and adjust tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-03-23 11:57:58 UTC
Size:
4.96 KB
patch
obsolete
>From 9a4b6ca1361b4592dae247359cd0197ed2042520 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 23 Jan 2020 02:37:19 +0000 >Subject: [PATCH] Bug 24476: Change CanBookBeRenewed and adjust tests > >Signed-off-by: Andrew <andrew@bywatersolutions.com> > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >--- > C4/Circulation.pm | 6 +++--- > t/db_dependent/Circulation.t | 26 +++++++++++++++++++++++++- > 2 files changed, 28 insertions(+), 4 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index cca192c6b0..a529b2ebbe 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2751,7 +2751,7 @@ sub CanBookBeRenewed { > return ( 0, 'overdue'); > } > >- if ( $issue->auto_renew ) { >+ if ( $issue->auto_renew && $patron->autorenewal ) { > > if ( $patron->category->effective_BlockExpiredPatronOpacActions and $patron->is_expired ) { > return ( 0, 'auto_account_expired' ); >@@ -2807,10 +2807,10 @@ sub CanBookBeRenewed { > > if ( $soonestrenewal > DateTime->now( time_zone => C4::Context->tz() ) ) > { >- return ( 0, "auto_too_soon" ) if $issue->auto_renew; >+ return ( 0, "auto_too_soon" ) if $issue->auto_renew && $patron->autorenewal; > return ( 0, "too_soon" ); > } >- elsif ( $issue->auto_renew ) { >+ elsif ( $issue->auto_renew && $patron->autorenewal ) { > $auto_renew = 1; > } > } >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 58ec966c17..f0d46df0ed 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -355,7 +355,8 @@ subtest "CanBookBeRenewed tests" => sub { > my $restricted_borrowernumber = Koha::Patron->new(\%restricted_borrower_data)->store->borrowernumber; > my $expired_borrowernumber = Koha::Patron->new(\%expired_borrower_data)->store->borrowernumber; > >- my $renewing_borrower = Koha::Patrons->find( $renewing_borrowernumber )->unblessed; >+ my $renewing_borrower_obj = Koha::Patrons->find( $renewing_borrowernumber ); >+ my $renewing_borrower = $renewing_borrower_obj->unblessed; > my $restricted_borrower = Koha::Patrons->find( $restricted_borrowernumber )->unblessed; > my $expired_borrower = Koha::Patrons->find( $expired_borrowernumber )->unblessed; > >@@ -656,6 +657,12 @@ subtest "CanBookBeRenewed tests" => sub { > > > >+ $renewing_borrower_obj->autorenewal(0)->store; >+ ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); >+ is( $renewokay, 1, 'No renewal before is undef, but patron opted out of auto_renewal' ); >+ $renewing_borrower_obj->autorenewal(1)->store; >+ >+ > # Bug 7413 > # Test premature manual renewal > Koha::CirculationRules->set_rule( >@@ -699,6 +706,12 @@ subtest "CanBookBeRenewed tests" => sub { > 'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' > ); > >+ $renewing_borrower_obj->autorenewal(0)->store; >+ ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); >+ is( $renewokay, 0, 'No renewal before is 7, patron opted out of auto_renewal still cannot renew early' ); >+ is( $error, 'too_soon', 'Error is too_soon, no auto' ); >+ $renewing_borrower_obj->autorenewal(1)->store; >+ > # Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) > # and test automatic renewal again > $dbh->do(q{UPDATE circulation_rules SET rule_value = '0' WHERE rule_name = 'norenewalbefore'}); >@@ -709,6 +722,12 @@ subtest "CanBookBeRenewed tests" => sub { > 'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' > ); > >+ $renewing_borrower_obj->autorenewal(0)->store; >+ ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); >+ is( $renewokay, 0, 'No renewal before is 0, patron opted out of auto_renewal still cannot renew early' ); >+ is( $error, 'too_soon', 'Error is too_soon, no auto' ); >+ $renewing_borrower_obj->autorenewal(1)->store; >+ > # Change policy so that loans can be renewed 99 days prior to the due date > # and test automatic renewal again > $dbh->do(q{UPDATE circulation_rules SET rule_value = '99' WHERE rule_name = 'norenewalbefore'}); >@@ -719,6 +738,11 @@ subtest "CanBookBeRenewed tests" => sub { > 'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' > ); > >+ $renewing_borrower_obj->autorenewal(0)->store; >+ ( $renewokay, $error ) = CanBookBeRenewed( $renewing_borrowernumber, $item_4->itemnumber ); >+ is( $renewokay, 1, 'No renewal before is 99, patron opted out of auto_renewal so can renew' ); >+ $renewing_borrower_obj->autorenewal(1)->store; >+ > subtest "too_late_renewal / no_auto_renewal_after" => sub { > plan tests => 14; > my $item_to_auto_renew = $builder->build( >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24476
:
97766
|
97767
|
97768
|
97769
|
97770
|
97831
|
97832
|
97833
|
97834
|
97835
|
97836
|
97923
|
97924
|
97925
|
97926
|
97927
|
97928
|
97997
|
97998
|
97999
|
98000
|
98001
|
98002
|
99793
|
99794
|
99795
|
99796
|
99797
|
99798
|
99799
|
99800
|
100022
|
100023
|
100024
|
100025
|
100026
|
100027
|
100028
|
100029
|
101385
|
101419
|
101420
|
101421
|
101422
|
101423
|
101424
|
101425
|
101426
|
101427
|
101511
|
101512
|
101513
|
101514
|
101515
|
101516
|
101517
|
101518
|
101519
|
101520
|
101521
|
101542