|
Lines 64-71
get '/biblios' => sub {
Link Here
|
| 64 |
$c->render( status => 200, json => {count => scalar(@$biblios), biblios => $biblios} ); |
64 |
$c->render( status => 200, json => {count => scalar(@$biblios), biblios => $biblios} ); |
| 65 |
}; |
65 |
}; |
| 66 |
|
66 |
|
|
|
67 |
get '/items/:item_id_1/:item_id_2' => sub { |
| 68 |
|
| 69 |
my $c = shift; |
| 70 |
|
| 71 |
# Emulate a public route by stashing the is_public value |
| 72 |
$c->stash( 'is_public' => 1 ); |
| 73 |
|
| 74 |
my $item_id_1 = $c->param('item_id_1'); |
| 75 |
my $item_id_2 = $c->param('item_id_2'); |
| 76 |
|
| 77 |
my $items_rs = Koha::Items->search({ itemnumber => [ $item_id_1, $item_id_2 ] }); |
| 78 |
my $items = $c->objects->search( $items_rs ); |
| 79 |
|
| 80 |
$c->render( |
| 81 |
status => 200, |
| 82 |
json => $items |
| 83 |
); |
| 84 |
}; |
| 85 |
|
| 67 |
# The tests |
86 |
# The tests |
| 68 |
use Test::More tests => 10; |
87 |
use Test::More tests => 11; |
| 69 |
use Test::Mojo; |
88 |
use Test::Mojo; |
| 70 |
|
89 |
|
| 71 |
use t::lib::Mocks; |
90 |
use t::lib::Mocks; |
|
Lines 412-415
subtest 'object.search helper order by embedded columns' => sub {
Link Here
|
| 412 |
->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second'); |
431 |
->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second'); |
| 413 |
|
432 |
|
| 414 |
$schema->storage->txn_begin; |
433 |
$schema->storage->txn_begin; |
| 415 |
} |
434 |
}; |
|
|
435 |
|
| 436 |
subtest 'objects.search helper, public requests' => sub { |
| 437 |
|
| 438 |
plan tests => 3; |
| 439 |
|
| 440 |
$schema->storage->txn_begin; |
| 441 |
|
| 442 |
my $item_1 = $builder->build_sample_item; |
| 443 |
my $item_2 = $builder->build_sample_item; |
| 444 |
|
| 445 |
my $t = Test::Mojo->new; |
| 446 |
|
| 447 |
$t->get_ok( '/items/'.$item_1->id.'/'.$item_2->id ) |
| 448 |
->json_is('/0' => $item_1->to_api({ public => 1 }), 'Public representation of $item_1 is retrieved') |
| 449 |
->json_is('/1' => $item_2->to_api({ public => 1 }), 'Public representation of $item_2 is retrieved'); |
| 450 |
|
| 451 |
$schema->storage->txn_rollback; |
| 452 |
}; |
| 416 |
- |
|
|