|
Lines 75-83
get '/biblios' => sub {
Link Here
|
| 75 |
$c->render( status => 200, json => {count => scalar(@$biblios), biblios => $biblios} ); |
75 |
$c->render( status => 200, json => {count => scalar(@$biblios), biblios => $biblios} ); |
| 76 |
}; |
76 |
}; |
| 77 |
|
77 |
|
|
|
78 |
get '/items/:item_id_1/:item_id_2' => sub { |
| 79 |
|
| 80 |
my $c = shift; |
| 81 |
|
| 82 |
# Emulate a public route by stashing the is_public value |
| 83 |
$c->stash( 'is_public' => 1 ); |
| 84 |
|
| 85 |
my $item_id_1 = $c->param('item_id_1'); |
| 86 |
my $item_id_2 = $c->param('item_id_2'); |
| 87 |
|
| 88 |
my $items_rs = Koha::Items->search({ itemnumber => [ $item_id_1, $item_id_2 ] }); |
| 89 |
my $items = $c->objects->search( $items_rs ); |
| 90 |
|
| 91 |
$c->render( |
| 92 |
status => 200, |
| 93 |
json => $items |
| 94 |
); |
| 95 |
}; |
| 78 |
|
96 |
|
| 79 |
# The tests |
97 |
# The tests |
| 80 |
use Test::More tests => 10; |
98 |
use Test::More tests => 11; |
| 81 |
use Test::Mojo; |
99 |
use Test::Mojo; |
| 82 |
|
100 |
|
| 83 |
use t::lib::Mocks; |
101 |
use t::lib::Mocks; |
|
Lines 423-426
subtest 'object.search helper order by embedded columns' => sub {
Link Here
|
| 423 |
->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second'); |
441 |
->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second'); |
| 424 |
|
442 |
|
| 425 |
$schema->storage->txn_begin; |
443 |
$schema->storage->txn_begin; |
| 426 |
} |
444 |
}; |
|
|
445 |
|
| 446 |
subtest 'objects.search helper, public requests' => sub { |
| 447 |
|
| 448 |
plan tests => 3; |
| 449 |
|
| 450 |
$schema->storage->txn_begin; |
| 451 |
|
| 452 |
my $item_1 = $builder->build_sample_item; |
| 453 |
my $item_2 = $builder->build_sample_item; |
| 454 |
|
| 455 |
my $t = Test::Mojo->new; |
| 456 |
|
| 457 |
$t->get_ok( '/items/'.$item_1->id.'/'.$item_2->id ) |
| 458 |
->json_is('/0' => $item_1->to_api({ public => 1 }), 'Public representation of $item_1 is retrieved') |
| 459 |
->json_is('/1' => $item_2->to_api({ public => 1 }), 'Public representation of $item_2 is retrieved'); |
| 460 |
|
| 461 |
$schema->storage->txn_rollback; |
| 462 |
}; |
| 427 |
- |
|
|