Lines 38-43
get '/cities' => sub {
Link Here
|
38 |
$c->render( status => 200, json => $cities ); |
38 |
$c->render( status => 200, json => $cities ); |
39 |
}; |
39 |
}; |
40 |
|
40 |
|
|
|
41 |
get '/cities/:city_id' => sub { |
42 |
my $c = shift; |
43 |
my $id = $c->stash("city_id"); |
44 |
my $city = $c->objects->find(Koha::Cities->new, $id); |
45 |
$c->render( status => 200, json => $city ); |
46 |
}; |
47 |
|
41 |
get '/orders' => sub { |
48 |
get '/orders' => sub { |
42 |
my $c = shift; |
49 |
my $c = shift; |
43 |
$c->stash('koha.embed', ( { fund => {} } ) ); |
50 |
$c->stash('koha.embed', ( { fund => {} } ) ); |
Lines 56-61
get '/patrons/:patron_id/holds' => sub {
Link Here
|
56 |
$c->render( status => 200, json => {count => scalar(@$holds)} ); |
63 |
$c->render( status => 200, json => {count => scalar(@$holds)} ); |
57 |
}; |
64 |
}; |
58 |
|
65 |
|
|
|
66 |
get '/orders/:order_id' => sub { |
67 |
my $c = shift; |
68 |
$c->stash('koha.embed', ( { fund => {} } ) ); |
69 |
my $id = $c->stash("order_id"); |
70 |
my $order = $c->objects->find(Koha::Acquisition::Orders->new, $id); |
71 |
$c->render( status => 200, json => $order ); |
72 |
}; |
73 |
|
59 |
get '/biblios' => sub { |
74 |
get '/biblios' => sub { |
60 |
my $c = shift; |
75 |
my $c = shift; |
61 |
my $output = $c->req->params->to_hash; |
76 |
my $output = $c->req->params->to_hash; |
Lines 77-83
get '/biblios' => sub {
Link Here
|
77 |
|
92 |
|
78 |
|
93 |
|
79 |
# The tests |
94 |
# The tests |
80 |
use Test::More tests => 10; |
95 |
use Test::More tests => 12; |
81 |
use Test::Mojo; |
96 |
use Test::Mojo; |
82 |
|
97 |
|
83 |
use t::lib::Mocks; |
98 |
use t::lib::Mocks; |
Lines 444-451
subtest 'object.search helper with all query methods' => sub {
Link Here
|
444 |
}; |
459 |
}; |
445 |
|
460 |
|
446 |
subtest 'object.search helper order by embedded columns' => sub { |
461 |
subtest 'object.search helper order by embedded columns' => sub { |
|
|
462 |
|
447 |
plan tests => 3; |
463 |
plan tests => 3; |
448 |
|
464 |
|
|
|
465 |
$schema->storage->txn_begin; |
466 |
|
449 |
my $patron1 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron1'} } ); |
467 |
my $patron1 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron1'} } ); |
450 |
my $patron2 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron2'} } ); |
468 |
my $patron2 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron2'} } ); |
451 |
my $biblio1 = $builder->build_sample_biblio; |
469 |
my $biblio1 = $builder->build_sample_biblio; |
Lines 458-462
subtest 'object.search helper order by embedded columns' => sub {
Link Here
|
458 |
->json_is('/biblios/0/biblio_id' => $biblio2->biblionumber, 'Biblio 2 should be first') |
476 |
->json_is('/biblios/0/biblio_id' => $biblio2->biblionumber, 'Biblio 2 should be first') |
459 |
->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second'); |
477 |
->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second'); |
460 |
|
478 |
|
|
|
479 |
$schema->storage->txn_rollback; |
480 |
}; |
481 |
|
482 |
subtest 'objects.find helper' => sub { |
483 |
|
484 |
plan tests => 6; |
485 |
|
486 |
my $t = Test::Mojo->new; |
487 |
|
461 |
$schema->storage->txn_begin; |
488 |
$schema->storage->txn_begin; |
462 |
} |
489 |
|
|
|
490 |
my $city_1 = $builder->build_object( { class => 'Koha::Cities' } ); |
491 |
my $city_2 = $builder->build_object( { class => 'Koha::Cities' } ); |
492 |
|
493 |
$t->get_ok( '/cities/' . $city_1->id ) |
494 |
->status_is(200) |
495 |
->json_is( $city_1->to_api ); |
496 |
|
497 |
$t->get_ok( '/cities/' . $city_2->id ) |
498 |
->status_is(200) |
499 |
->json_is( $city_2->to_api ); |
500 |
|
501 |
$schema->storage->txn_rollback; |
502 |
}; |
503 |
|
504 |
subtest 'objects.find helper, embed' => sub { |
505 |
|
506 |
plan tests => 2; |
507 |
|
508 |
my $t = Test::Mojo->new; |
509 |
|
510 |
$schema->storage->txn_begin; |
511 |
|
512 |
my $order = $builder->build_object({ class => 'Koha::Acquisition::Orders' }); |
513 |
|
514 |
$t->get_ok( '/orders/' . $order->ordernumber ) |
515 |
->json_is( $order->to_api( { embed => ( { fund => {} } ) } ) ); |
516 |
|
517 |
$schema->storage->txn_rollback; |
518 |
}; |
463 |
- |
|
|