Lines 79-86
get '/biblios' => sub {
Link Here
|
79 |
$c->render( status => 200, json => {count => scalar(@$biblios), biblios => $biblios} ); |
79 |
$c->render( status => 200, json => {count => scalar(@$biblios), biblios => $biblios} ); |
80 |
}; |
80 |
}; |
81 |
|
81 |
|
|
|
82 |
get '/items/:item_id_1/:item_id_2' => sub { |
83 |
|
84 |
my $c = shift; |
85 |
|
86 |
# Emulate a public route by stashing the is_public value |
87 |
$c->stash( 'is_public' => 1 ); |
88 |
|
89 |
my $item_id_1 = $c->param('item_id_1'); |
90 |
my $item_id_2 = $c->param('item_id_2'); |
91 |
|
92 |
my $items_rs = Koha::Items->search({ itemnumber => [ $item_id_1, $item_id_2 ] }); |
93 |
my $items = $c->objects->search( $items_rs ); |
94 |
|
95 |
$c->render( |
96 |
status => 200, |
97 |
json => $items |
98 |
); |
99 |
}; |
100 |
|
82 |
# The tests |
101 |
# The tests |
83 |
use Test::More tests => 12; |
102 |
use Test::More tests => 13; |
84 |
use Test::Mojo; |
103 |
use Test::Mojo; |
85 |
|
104 |
|
86 |
use t::lib::Mocks; |
105 |
use t::lib::Mocks; |
Lines 512-514
subtest 'objects.find helper, embed' => sub {
Link Here
|
512 |
|
531 |
|
513 |
$schema->storage->txn_rollback; |
532 |
$schema->storage->txn_rollback; |
514 |
}; |
533 |
}; |
515 |
- |
534 |
|
|
|
535 |
subtest 'objects.search helper, public requests' => sub { |
536 |
|
537 |
plan tests => 3; |
538 |
|
539 |
$schema->storage->txn_begin; |
540 |
|
541 |
my $item_1 = $builder->build_sample_item; |
542 |
my $item_2 = $builder->build_sample_item; |
543 |
|
544 |
my $t = Test::Mojo->new; |
545 |
|
546 |
$t->get_ok( '/items/'.$item_1->id.'/'.$item_2->id ) |
547 |
->json_is('/0' => $item_1->to_api({ public => 1 }), 'Public representation of $item_1 is retrieved') |
548 |
->json_is('/1' => $item_2->to_api({ public => 1 }), 'Public representation of $item_2 is retrieved'); |
549 |
|
550 |
$schema->storage->txn_rollback; |
551 |
}; |