From bb44f6971d6c8dfe4401ab979329d8a50ccf4de6 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 20 Jun 2024 11:05:07 +0100 Subject: [PATCH] Bug 36428: (QA follow-up) Remove filter_by_future I actually already started to remove this in another bug, but it makes sense to do it here where we're introducing the 'active' filter. I'm in agreement that this should probably always have been an 'active' rather than 'future' filtering. Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer (cherry picked from commit 39920e03f1b7975cfea71345279235b9e9f5ecbb) Signed-off-by: Lucas Gass --- Koha/Bookings.pm | 13 -------- t/db_dependent/Koha/Bookings.t | 60 +--------------------------------- 2 files changed, 1 insertion(+), 72 deletions(-) diff --git a/Koha/Bookings.pm b/Koha/Bookings.pm index d4c89b4278..86eeb3a5c8 100644 --- a/Koha/Bookings.pm +++ b/Koha/Bookings.pm @@ -32,19 +32,6 @@ Koha::Bookings - Koha Booking object set class =head2 Class Methods -=head3 filter_by_future - - $bookings->filter_by_future; - -Will return the bookings starting from now. - -=cut - -sub filter_by_future { - my ($self) = @_; - return $self->search( { start_date => { '>' => \'NOW()' } } ); -} - =head3 filter_by_active $bookings->filter_by_active; diff --git a/t/db_dependent/Koha/Bookings.t b/t/db_dependent/Koha/Bookings.t index 9d29e4c2e8..699daaebab 100755 --- a/t/db_dependent/Koha/Bookings.t +++ b/t/db_dependent/Koha/Bookings.t @@ -19,7 +19,7 @@ use Modern::Perl; -use Test::More tests => 2; +use Test::More tests => 1; use Koha::Bookings; use Koha::Database; @@ -31,64 +31,6 @@ my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; -subtest 'filter_by_future' => sub { - - plan tests => 2; - - $schema->storage->txn_begin; - - my $biblio = $builder->build_sample_biblio; - $builder->build_object( - { - class => 'Koha::Bookings', - value => { - biblio_id => $biblio->biblionumber, - start_date => dt_from_string->subtract( days => 1 )->truncate( to => 'day' ), - end_date => undef - } - } - ); - - $builder->build_object( - { - class => 'Koha::Bookings', - value => { - biblio_id => $biblio->biblionumber, - start_date => dt_from_string->add( days => 1 )->truncate( to => 'day' ), - end_date => undef - } - } - ); - - $builder->build_object( - { - class => 'Koha::Bookings', - value => { - biblio_id => $biblio->biblionumber, - start_date => dt_from_string->add( days => 2 )->truncate( to => 'day' ), - end_date => undef - } - } - ); - - is( $biblio->bookings->filter_by_future->count, 2, 'There should have 2 bookings starting after now' ); - - $builder->build_object( - { - class => 'Koha::Bookings', - value => { - biblio_id => $biblio->biblionumber, - start_date => dt_from_string->truncate( to => 'day' ), - end_date => undef - } - } - ); - - is( $biblio->bookings->filter_by_future->count, 2, 'Current day is not considered future' ); - - $schema->storage->txn_rollback; -}; - subtest 'filter_by_active' => sub { plan tests => 5; -- 2.39.5