Bugzilla – Attachment 161253 Details for
Bug 29510
objects.find should call search_limited if present
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29510: Regression tests
Bug-29510-Regression-tests.patch (text/plain), 3.05 KB, created by
Martin Renvoize (ashimema)
on 2024-01-22 16:34:54 UTC
(
hide
)
Description:
Bug 29510: Regression tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-01-22 16:34:54 UTC
Size:
3.05 KB
patch
obsolete
>From 5de26c1a657557983b1b79ddb766177e267fe996 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 17 Nov 2021 18:02:17 -0300 >Subject: [PATCH] Bug 29510: Regression tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Koha/REST/Plugin/Objects.t | 57 ++++++++++++++++++++++- > 1 file changed, 55 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/REST/Plugin/Objects.t b/t/db_dependent/Koha/REST/Plugin/Objects.t >index b0eebbd492c..d649f4f4ab6 100755 >--- a/t/db_dependent/Koha/REST/Plugin/Objects.t >+++ b/t/db_dependent/Koha/REST/Plugin/Objects.t >@@ -138,8 +138,21 @@ get '/cities/:city_id/rs' => sub { > $c->render( status => 200, json => { name => $city->city_name } ); > }; > >+get '/my_patrons/:patron_id' => sub { >+ >+ my $c = shift; >+ >+ my $patron_id = $c->param('patron_id'); >+ my $patron = $c->objects->find( scalar Koha::Patrons->new, $patron_id ); >+ >+ $c->render( >+ status => 200, >+ json => $patron >+ ); >+}; >+ > # The tests >-use Test::More tests => 17; >+use Test::More tests => 18; > use Test::Mojo; > > use t::lib::Mocks; >@@ -907,7 +920,6 @@ subtest 'objects.search helper with expanded authorised values' => sub { > ->json_is( '/0/name' => 'Manuel' )->json_hasnt('/0/_strings') > ->json_is( '/1/name' => 'Manuela' )->json_hasnt('/1/_strings'); > >- > $schema->storage->txn_rollback; > }; > >@@ -963,3 +975,44 @@ subtest 'objects.find_rs helper' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'objects.find helper, search_limited() tests' => sub { >+ >+ plan tests => 12; >+ >+ $schema->storage->txn_begin; >+ >+ my $library_1 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $library_2 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ >+ my $patron_1 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library_1->id } } ); >+ my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library_2->id } } ); >+ >+ my @libraries_where_can_see_patrons = ( $library_1->id, $library_2->id ); >+ >+ my $t = Test::Mojo->new; >+ >+ my $mocked_patron = Test::MockModule->new('Koha::Patron'); >+ $mocked_patron->mock( >+ 'libraries_where_can_see_patrons', >+ sub { >+ return @libraries_where_can_see_patrons; >+ } >+ ); >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ t::lib::Mocks::mock_userenv( { patron => $patron } ); >+ >+ $t->get_ok( "/my_patrons/" . $patron_1->id )->status_is(200)->json_is( '/patron_id' => $patron_1->id ); >+ >+ $t->get_ok( "/my_patrons/" . $patron_2->id )->status_is(200)->json_is( '/patron_id' => $patron_2->id ); >+ >+ @libraries_where_can_see_patrons = ( $library_2->id ); >+ >+ $t->get_ok( "/my_patrons/" . $patron_1->id )->status_is(200)->json_is(undef); >+ >+ $t->get_ok( "/my_patrons/" . $patron_2->id )->status_is(200)->json_is( '/patron_id' => $patron_2->id ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >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 29510
:
127759
|
127760
|
127761
|
127772
|
127773
|
127774
|
161253
|
161254
|
161255
|
161477
|
161478
|
161479