Lines 38-43
plugin 'Koha::REST::Plugin::Pagination';
Link Here
|
38 |
get '/cities' => sub { |
38 |
get '/cities' => sub { |
39 |
my $c = shift; |
39 |
my $c = shift; |
40 |
$c->validation->output($c->req->params->to_hash); |
40 |
$c->validation->output($c->req->params->to_hash); |
|
|
41 |
$c->stash_embed; |
41 |
my $cities = $c->objects->search(Koha::Cities->new); |
42 |
my $cities = $c->objects->search(Koha::Cities->new); |
42 |
$c->render( status => 200, json => $cities ); |
43 |
$c->render( status => 200, json => $cities ); |
43 |
}; |
44 |
}; |
Lines 45-50
get '/cities' => sub {
Link Here
|
45 |
get '/cities/:city_id' => sub { |
46 |
get '/cities/:city_id' => sub { |
46 |
my $c = shift; |
47 |
my $c = shift; |
47 |
my $id = $c->stash("city_id"); |
48 |
my $id = $c->stash("city_id"); |
|
|
49 |
$c->stash_embed; |
48 |
my $city = $c->objects->find(Koha::Cities->new, $id); |
50 |
my $city = $c->objects->find(Koha::Cities->new, $id); |
49 |
$c->render( status => 200, json => $city ); |
51 |
$c->render( status => 200, json => $city ); |
50 |
}; |
52 |
}; |
Lines 712-718
subtest 'objects.find helper with expanded authorised values' => sub {
Link Here
|
712 |
} |
714 |
} |
713 |
); |
715 |
); |
714 |
|
716 |
|
715 |
$t->get_ok( '/cities/' . $manuel->id => { 'x-koha-av-expand' => 1 } ) |
717 |
$t->get_ok( '/cities/' . $manuel->id => { 'x-koha-embed' => '+av_expand' } ) |
716 |
->status_is(200)->json_is( '/name' => 'Manuel' ) |
718 |
->status_is(200)->json_is( '/name' => 'Manuel' ) |
717 |
->json_has('/_str') |
719 |
->json_has('/_str') |
718 |
->json_is( '/_str/country/type' => 'av' ) |
720 |
->json_is( '/_str/country/type' => 'av' ) |
Lines 723-729
subtest 'objects.find helper with expanded authorised values' => sub {
Link Here
|
723 |
->status_is(200)->json_is( '/name' => 'Manuel' ) |
725 |
->status_is(200)->json_is( '/name' => 'Manuel' ) |
724 |
->json_hasnt('/_str'); |
726 |
->json_hasnt('/_str'); |
725 |
|
727 |
|
726 |
$t->get_ok( '/cities/' . $manuela->id => { 'x-koha-av-expand' => 1 } ) |
728 |
$t->get_ok( '/cities/' . $manuela->id => { 'x-koha-embed' => '+av_expand' } ) |
727 |
->status_is(200)->json_is( '/name' => 'Manuela' ) |
729 |
->status_is(200)->json_is( '/name' => 'Manuela' ) |
728 |
->json_has('/_str') |
730 |
->json_has('/_str') |
729 |
->json_is( '/_str/country/type' => 'av' ) |
731 |
->json_is( '/_str/country/type' => 'av' ) |
Lines 827-833
subtest 'objects.search helper with expanded authorised values' => sub {
Link Here
|
827 |
); |
829 |
); |
828 |
|
830 |
|
829 |
$t->get_ok( '/cities?name=manuel&_per_page=4&_page=1&_match=starts_with' => |
831 |
$t->get_ok( '/cities?name=manuel&_per_page=4&_page=1&_match=starts_with' => |
830 |
{ 'x-koha-av-expand' => 1 } )->status_is(200) |
832 |
{ 'x-koha-embed' => '+av_expand' } )->status_is(200) |
831 |
->json_has('/0')->json_has('/1')->json_hasnt('/2') |
833 |
->json_has('/0')->json_has('/1')->json_hasnt('/2') |
832 |
->json_is( '/0/name' => 'Manuel' ) |
834 |
->json_is( '/0/name' => 'Manuel' ) |
833 |
->json_has('/0/_str') |
835 |
->json_has('/0/_str') |
Lines 840-847
subtest 'objects.search helper with expanded authorised values' => sub {
Link Here
|
840 |
->json_is( '/1/_str/country/type' => 'av' ) |
842 |
->json_is( '/1/_str/country/type' => 'av' ) |
841 |
->json_is( '/1/_str/country/category' => $cat->category_name ); |
843 |
->json_is( '/1/_str/country/category' => $cat->category_name ); |
842 |
|
844 |
|
843 |
$t->get_ok( '/cities?name=manuel&_per_page=4&_page=1&_match=starts_with' => |
845 |
$t->get_ok( '/cities?name=manuel&_per_page=4&_page=1&_match=starts_with' )->status_is(200) |
844 |
{ 'x-koha-av-expand' => 0 } )->status_is(200) |
|
|
845 |
->json_has('/0')->json_has('/1')->json_hasnt('/2') |
846 |
->json_has('/0')->json_has('/1')->json_hasnt('/2') |
846 |
->json_is( '/0/name' => 'Manuel' )->json_hasnt('/0/_str') |
847 |
->json_is( '/0/name' => 'Manuel' )->json_hasnt('/0/_str') |
847 |
->json_is( '/1/name' => 'Manuela' )->json_hasnt('/1/_str'); |
848 |
->json_is( '/1/name' => 'Manuela' )->json_hasnt('/1/_str'); |
848 |
- |
|
|