Bugzilla – Attachment 125638 Details for
Bug 27945
Limit the number of active article requests per patron category
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27945: Clarify 'same day' behavior
Bug-27945-Clarify-same-day-behavior.patch (text/plain), 4.20 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-10-01 20:27:10 UTC
(
hide
)
Description:
Bug 27945: Clarify 'same day' behavior
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-10-01 20:27:10 UTC
Size:
4.20 KB
patch
obsolete
>From b4de64c0ed0b63f92fdecb5d60bdd0cb273757b4 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 1 Oct 2021 12:42:24 -0300 >Subject: [PATCH] Bug 27945: Clarify 'same day' behavior > >This patch introduces tests for the 'same day' check of the ability to >place article requests for a patron. > >The limit goes against current requests, and those that have been >completed on the same day. The tests cover this specific situation. > >The current behavior is that it takes into account a 24 hr timespan, but >consensus on the QA step was that we should do it as 'same day' and use >a separate feature request to change this, if required. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Patron.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Patron.pm | 11 ++++---- > t/db_dependent/Koha/Patron.t | 54 +++++++++++++++++++++++++++++++++++- > 2 files changed, 58 insertions(+), 7 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 6436d18bb6..7dd35cd455 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -973,12 +973,11 @@ sub can_request_article { > > return 1 unless defined $limit; > >- my $dtf = Koha::Database->new->schema->storage->datetime_parser; >- my $compdate = dt_from_string->add( days => -1 ); >- my $count = Koha::ArticleRequests->search([ >- { borrowernumber => $self->borrowernumber, status => ['REQUESTED','PENDING','PROCESSING'] }, >- { borrowernumber => $self->borrowernumber, status => 'COMPLETED', updated_on => { '>', $dtf->format_date($compdate) }}, >- ])->count; >+ my $count = Koha::ArticleRequests->search( >+ [ { borrowernumber => $self->borrowernumber, status => [ 'REQUESTED', 'PENDING', 'PROCESSING' ] }, >+ { borrowernumber => $self->borrowernumber, status => 'COMPLETED', updated_on => { '>=' => \'DATE(NOW())' } }, >+ ] >+ )->count; > return $count < $limit ? 1 : 0; > } > >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index b088d2a5b2..0d62df241c 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 9; >+use Test::More tests => 10; > use Test::Exception; > use Test::Warn; > >@@ -831,3 +831,55 @@ subtest 'can_request_article() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'can_request_article() tests' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $category = $builder->build_object( >+ { >+ class => 'Koha::Patron::Categories', >+ value => { article_request_limit => 4 } >+ } >+ ); >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { categorycode => $category->id } >+ } >+ ); >+ >+ $builder->build_object( { class => 'Koha::ArticleRequests', value => { status => 'REQUESTED', borrowernumber => $patron->id } } ); >+ $builder->build_object( { class => 'Koha::ArticleRequests', value => { status => 'PENDING', borrowernumber => $patron->id } } ); >+ $builder->build_object( { class => 'Koha::ArticleRequests', value => { status => 'PROCESSING', borrowernumber => $patron->id } } ); >+ $builder->build_object( { class => 'Koha::ArticleRequests', value => { status => 'CANCELED', borrowernumber => $patron->id } } ); >+ >+ ok( $patron->can_request_article, 'Patron has 3 current requests, 4 is the limit: allowed' ); >+ >+ # Completed request, same day >+ my $completed = $builder->build_object( >+ { >+ class => 'Koha::ArticleRequests', >+ value => { >+ status => 'COMPLETED', >+ borrowernumber => $patron->id >+ } >+ } >+ ); >+ >+ ok( !$patron->can_request_article, 'Patron has 3 current requests and a completed one the same day: denied' ); >+ >+ $completed->updated_on( >+ dt_from_string->add( days => -1 )->set( >+ hour => 23, >+ minute => 59, >+ second => 59, >+ ) >+ )->store; >+ >+ ok( $patron->can_request_article, 'Patron has 3 current requests and a completed one the day before: allowed' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.33.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 27945
:
123217
|
123218
|
123219
|
123220
|
123714
|
123715
|
123774
|
123775
|
123776
|
123777
|
123778
|
123820
|
124066
|
124067
|
124068
|
124069
|
124070
|
124071
|
124072
|
124073
|
124074
|
124075
|
124076
|
124077
|
124078
|
124079
|
124284
|
124285
|
124633
|
124673
|
124674
|
124675
|
124676
|
124677
|
124678
|
124679
|
124680
|
124681
|
124682
|
125140
|
125142
|
125143
|
125144
|
125145
|
125146
|
125147
|
125148
|
125149
|
125150
|
125151
|
125152
|
125178
|
125179
|
125569
|
125571
|
125638
|
125690
|
125702
|
125703
|
125704
|
125705
|
125706
|
125707
|
125726
|
125741
|
125761