Lines 138-145
get '/cities/:city_id/rs' => sub {
Link Here
|
138 |
$c->render( status => 200, json => { name => $city->city_name } ); |
138 |
$c->render( status => 200, json => { name => $city->city_name } ); |
139 |
}; |
139 |
}; |
140 |
|
140 |
|
|
|
141 |
get '/my_patrons/:patron_id' => sub { |
142 |
|
143 |
my $c = shift; |
144 |
|
145 |
my $patron_id = $c->param('patron_id'); |
146 |
my $patron = $c->objects->find( scalar Koha::Patrons->new, $patron_id ); |
147 |
|
148 |
$c->render( |
149 |
status => 200, |
150 |
json => $patron |
151 |
); |
152 |
}; |
153 |
|
141 |
# The tests |
154 |
# The tests |
142 |
use Test::More tests => 17; |
155 |
use Test::More tests => 18; |
143 |
use Test::Mojo; |
156 |
use Test::Mojo; |
144 |
|
157 |
|
145 |
use t::lib::Mocks; |
158 |
use t::lib::Mocks; |
Lines 907-913
subtest 'objects.search helper with expanded authorised values' => sub {
Link Here
|
907 |
->json_is( '/0/name' => 'Manuel' )->json_hasnt('/0/_strings') |
920 |
->json_is( '/0/name' => 'Manuel' )->json_hasnt('/0/_strings') |
908 |
->json_is( '/1/name' => 'Manuela' )->json_hasnt('/1/_strings'); |
921 |
->json_is( '/1/name' => 'Manuela' )->json_hasnt('/1/_strings'); |
909 |
|
922 |
|
910 |
|
|
|
911 |
$schema->storage->txn_rollback; |
923 |
$schema->storage->txn_rollback; |
912 |
}; |
924 |
}; |
913 |
|
925 |
|
Lines 963-965
subtest 'objects.find_rs helper' => sub {
Link Here
|
963 |
|
975 |
|
964 |
$schema->storage->txn_rollback; |
976 |
$schema->storage->txn_rollback; |
965 |
}; |
977 |
}; |
966 |
- |
978 |
|
|
|
979 |
subtest 'objects.find helper, search_limited() tests' => sub { |
980 |
|
981 |
plan tests => 12; |
982 |
|
983 |
$schema->storage->txn_begin; |
984 |
|
985 |
my $library_1 = $builder->build_object( { class => 'Koha::Libraries' } ); |
986 |
my $library_2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
987 |
|
988 |
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library_1->id } } ); |
989 |
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons', value => { branchcode => $library_2->id } } ); |
990 |
|
991 |
my @libraries_where_can_see_patrons = ( $library_1->id, $library_2->id ); |
992 |
|
993 |
my $t = Test::Mojo->new; |
994 |
|
995 |
my $mocked_patron = Test::MockModule->new('Koha::Patron'); |
996 |
$mocked_patron->mock( |
997 |
'libraries_where_can_see_patrons', |
998 |
sub { |
999 |
return @libraries_where_can_see_patrons; |
1000 |
} |
1001 |
); |
1002 |
|
1003 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
1004 |
|
1005 |
t::lib::Mocks::mock_userenv( { patron => $patron } ); |
1006 |
|
1007 |
$t->get_ok( "/my_patrons/" . $patron_1->id )->status_is(200)->json_is( '/patron_id' => $patron_1->id ); |
1008 |
|
1009 |
$t->get_ok( "/my_patrons/" . $patron_2->id )->status_is(200)->json_is( '/patron_id' => $patron_2->id ); |
1010 |
|
1011 |
@libraries_where_can_see_patrons = ( $library_2->id ); |
1012 |
|
1013 |
$t->get_ok( "/my_patrons/" . $patron_1->id )->status_is(200)->json_is(undef); |
1014 |
|
1015 |
$t->get_ok( "/my_patrons/" . $patron_2->id )->status_is(200)->json_is( '/patron_id' => $patron_2->id ); |
1016 |
|
1017 |
$schema->storage->txn_rollback; |
1018 |
}; |