|
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 '/libraries/:library_id_1/:library_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 $library_id_1 = $c->param('library_id_1'); |
| 90 |
my $library_id_2 = $c->param('library_id_2'); |
| 91 |
|
| 92 |
my $libraries_rs = Koha::Libraries->search({ branchcode => [ $library_id_1, $library_id_2 ] }); |
| 93 |
my $libraries = $c->objects->search( $libraries_rs ); |
| 94 |
|
| 95 |
$c->render( |
| 96 |
status => 200, |
| 97 |
json => $libraries |
| 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 $library_1 = $builder->build_object({ class => 'Koha::Libraries' }); |
| 542 |
my $library_2 = $builder->build_object({ class => 'Koha::Libraries' }); |
| 543 |
|
| 544 |
my $t = Test::Mojo->new; |
| 545 |
|
| 546 |
$t->get_ok( '/libraries/'.$library_1->id.'/'.$library_2->id ) |
| 547 |
->json_is('/0' => $library_1->to_api({ public => 1 }), 'Public representation of $library_1 is retrieved') |
| 548 |
->json_is('/1' => $library_2->to_api({ public => 1 }), 'Public representation of $library_2 is retrieved'); |
| 549 |
|
| 550 |
$schema->storage->txn_rollback; |
| 551 |
}; |