Bugzilla – Attachment 159795 Details for
Bug 35468
Bookings permission mismatch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35468: (follow-up) Fix QA complaints
Bug-35468-follow-up-Fix-QA-complaints.patch (text/plain), 5.55 KB, created by
Tomás Cohen Arazi (tcohen)
on 2023-12-13 12:45:10 UTC
(
hide
)
Description:
Bug 35468: (follow-up) Fix QA complaints
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2023-12-13 12:45:10 UTC
Size:
5.55 KB
patch
obsolete
>From e188075068b3b9621badd8232b7f2e6304f7ceb0 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 12 Dec 2023 16:37:49 +0000 >Subject: [PATCH] Bug 35468: (follow-up) Fix QA complaints > >Tidyness >Use dt_from_string, not DateTime->now >Add exec flag > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/api/v1/bookings.t | 33 ++++++++++++++++---------------- > 1 file changed, 17 insertions(+), 16 deletions(-) > mode change 100644 => 100755 t/db_dependent/api/v1/bookings.t > >diff --git a/t/db_dependent/api/v1/bookings.t b/t/db_dependent/api/v1/bookings.t >old mode 100644 >new mode 100755 >index f581a25de7e..e5eb75120e6 >--- a/t/db_dependent/api/v1/bookings.t >+++ b/t/db_dependent/api/v1/bookings.t >@@ -27,6 +27,7 @@ use JSON qw(encode_json); > > use Koha::Bookings; > use Koha::Database; >+use Koha::DateUtils qw (dt_from_string); > > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; >@@ -70,8 +71,8 @@ subtest 'list() tests' => sub { > $t->get_ok("//$userid:$password@/api/v1/bookings")->status_is(200)->json_is( [] ); > > # One booking >- my $start_0 = DateTime->now->subtract( days => 2 )->truncate( to => 'day' ); >- my $end_0 = DateTime->now->add( days => 4 )->truncate( to => 'day' ); >+ my $start_0 = dt_from_string->subtract( days => 2 )->truncate( to => 'day' ); >+ my $end_0 = dt_from_string->add( days => 4 )->truncate( to => 'day' ); > my $booking_0 = $builder->build_object( > { > class => 'Koha::Bookings', >@@ -85,8 +86,8 @@ subtest 'list() tests' => sub { > $t->get_ok("//$userid:$password@/api/v1/bookings")->status_is(200)->json_is( [ $booking_0->to_api ] ); > > # More bookings >- my $start_1 = DateTime->now->add( days => 1 )->truncate( to => 'day' ); >- my $end_1 = DateTime->now->add( days => 6 )->truncate( to => 'day' ); >+ my $start_1 = dt_from_string->add( days => 1 )->truncate( to => 'day' ); >+ my $end_1 = dt_from_string->add( days => 6 )->truncate( to => 'day' ); > my $booking_1 = $builder->build_object( > { > class => 'Koha::Bookings', >@@ -97,8 +98,8 @@ subtest 'list() tests' => sub { > } > ); > >- my $start_2 = DateTime->now->add( days => 4 )->truncate( to => 'day' ); >- my $end_2 = DateTime->now->add( days => 8 )->truncate( to => 'day' ); >+ my $start_2 = dt_from_string->add( days => 4 )->truncate( to => 'day' ); >+ my $end_2 = dt_from_string->add( days => 8 )->truncate( to => 'day' ); > my $booking_2 = $builder->build_object( > { > class => 'Koha::Bookings', >@@ -120,7 +121,7 @@ subtest 'list() tests' => sub { > ); > > # Filtering works, two bookings after today >- my $api_filter = encode_json( { 'me.start_date' => { '>=' => DateTime->now->rfc3339 } } ); >+ my $api_filter = encode_json( { 'me.start_date' => { '>=' => dt_from_string->rfc3339 } } ); > $t->get_ok("//$userid:$password@/api/v1/bookings?q=$api_filter")->status_is(200)->json_is( > '' => [ > $booking_1->to_api, >@@ -129,7 +130,7 @@ subtest 'list() tests' => sub { > 'filtered returns two future bookings' > ); > >- $api_filter = encode_json( { 'me.start_date' => { '<=' => DateTime->now->rfc3339 } } ); >+ $api_filter = encode_json( { 'me.start_date' => { '<=' => dt_from_string->rfc3339 } } ); > $t->get_ok("//$userid:$password@/api/v1/bookings?q=$api_filter")->status_is(200) > ->json_is( '' => [ $booking_0->to_api ], 'filtering to before today also works' ); > >@@ -216,8 +217,8 @@ subtest 'add() tests' => sub { > biblio_id => $biblio->id, > item_id => undef, > patron_id => $patron->id, >- start_date => DateTime->now->add( days => 2 )->rfc3339, >- end_date => DateTime->now->add( days => 6 )->rfc3339, >+ start_date => dt_from_string->add( days => 2 )->rfc3339, >+ end_date => dt_from_string->add( days => 6 )->rfc3339, > }; > > # Unauthorized attempt to write >@@ -303,8 +304,8 @@ subtest 'update() tests' => sub { > my $booking_with_missing_field = { > item_id => undef, > patron_id => $patron->id, >- start_date => DateTime->now->add( days => 2 )->rfc3339, >- end_date => DateTime->now->add( days => 6 )->rfc3339, >+ start_date => dt_from_string->add( days => 2 )->rfc3339, >+ end_date => dt_from_string->add( days => 6 )->rfc3339, > }; > > $t->put_ok( "//$userid:$password@/api/v1/bookings/$booking_id" => json => $booking_with_missing_field ) >@@ -315,8 +316,8 @@ subtest 'update() tests' => sub { > biblio_id => $biblio->id, > item_id => undef, > patron_id => $patron->id, >- start_date => DateTime->now->add( days => 2 )->rfc3339, >- end_date => DateTime->now->add( days => 6 )->rfc3339, >+ start_date => dt_from_string->add( days => 2 )->rfc3339, >+ end_date => dt_from_string->add( days => 6 )->rfc3339, > }; > > $t->put_ok( "//$userid:$password@/api/v1/bookings/$booking_id" => json => $booking_with_updated_field ) >@@ -328,8 +329,8 @@ subtest 'update() tests' => sub { > biblio_id => $biblio->id, > item_id => undef, > patron_id => $patron->id, >- start_date => DateTime->now->add( days => 2 )->rfc3339, >- end_date => DateTime->now->add( days => 6 )->rfc3339, >+ start_date => dt_from_string->add( days => 2 )->rfc3339, >+ end_date => dt_from_string->add( days => 6 )->rfc3339, > }; > > $t->put_ok( "//$userid:$password@/api/v1/bookings/$booking_id" => json => $booking_with_invalid_field ) >-- >2.43.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 35468
:
159734
|
159746
|
159754
|
159755
|
159756
|
159757
|
159789
|
159790
|
159791
|
159792
|
159793
|
159794
| 159795 |
159796
|
159881