Lines 37-42
get '/cities' => sub {
Link Here
|
37 |
$c->render( status => 200, json => $cities ); |
37 |
$c->render( status => 200, json => $cities ); |
38 |
}; |
38 |
}; |
39 |
|
39 |
|
|
|
40 |
get '/cities/:city_id' => sub { |
41 |
my $c = shift; |
42 |
my $id = $c->stash("city_id"); |
43 |
my $city = $c->objects->find(Koha::Cities->new, $id); |
44 |
$c->render( status => 200, json => $city ); |
45 |
}; |
46 |
|
40 |
get '/orders' => sub { |
47 |
get '/orders' => sub { |
41 |
my $c = shift; |
48 |
my $c = shift; |
42 |
$c->stash('koha.embed', ( { fund => {} } ) ); |
49 |
$c->stash('koha.embed', ( { fund => {} } ) ); |
Lines 45-50
get '/orders' => sub {
Link Here
|
45 |
$c->render( status => 200, json => $orders ); |
52 |
$c->render( status => 200, json => $orders ); |
46 |
}; |
53 |
}; |
47 |
|
54 |
|
|
|
55 |
get '/orders/:order_id' => sub { |
56 |
my $c = shift; |
57 |
$c->stash('koha.embed', ( { fund => {} } ) ); |
58 |
my $id = $c->stash("order_id"); |
59 |
my $order = $c->objects->find(Koha::Acquisition::Orders->new, $id); |
60 |
$c->render( status => 200, json => $order ); |
61 |
}; |
62 |
|
48 |
get '/biblios' => sub { |
63 |
get '/biblios' => sub { |
49 |
my $c = shift; |
64 |
my $c = shift; |
50 |
my $output = $c->req->params->to_hash; |
65 |
my $output = $c->req->params->to_hash; |
Lines 65-71
get '/biblios' => sub {
Link Here
|
65 |
}; |
80 |
}; |
66 |
|
81 |
|
67 |
# The tests |
82 |
# The tests |
68 |
use Test::More tests => 10; |
83 |
use Test::More tests => 12; |
69 |
use Test::Mojo; |
84 |
use Test::Mojo; |
70 |
|
85 |
|
71 |
use t::lib::Mocks; |
86 |
use t::lib::Mocks; |
Lines 433-440
subtest 'object.search helper with all query methods' => sub {
Link Here
|
433 |
}; |
448 |
}; |
434 |
|
449 |
|
435 |
subtest 'object.search helper order by embedded columns' => sub { |
450 |
subtest 'object.search helper order by embedded columns' => sub { |
|
|
451 |
|
436 |
plan tests => 3; |
452 |
plan tests => 3; |
437 |
|
453 |
|
|
|
454 |
$schema->storage->txn_begin; |
455 |
|
438 |
my $patron1 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron1'} } ); |
456 |
my $patron1 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron1'} } ); |
439 |
my $patron2 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron2'} } ); |
457 |
my $patron2 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron2'} } ); |
440 |
my $biblio1 = $builder->build_sample_biblio; |
458 |
my $biblio1 = $builder->build_sample_biblio; |
Lines 447-451
subtest 'object.search helper order by embedded columns' => sub {
Link Here
|
447 |
->json_is('/biblios/0/biblio_id' => $biblio2->biblionumber, 'Biblio 2 should be first') |
465 |
->json_is('/biblios/0/biblio_id' => $biblio2->biblionumber, 'Biblio 2 should be first') |
448 |
->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second'); |
466 |
->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second'); |
449 |
|
467 |
|
|
|
468 |
$schema->storage->txn_rollback; |
469 |
}; |
470 |
|
471 |
subtest 'objects.find helper' => sub { |
472 |
|
473 |
plan tests => 6; |
474 |
|
475 |
my $t = Test::Mojo->new; |
476 |
|
450 |
$schema->storage->txn_begin; |
477 |
$schema->storage->txn_begin; |
451 |
} |
478 |
|
|
|
479 |
my $city_1 = $builder->build_object( { class => 'Koha::Cities' } ); |
480 |
my $city_2 = $builder->build_object( { class => 'Koha::Cities' } ); |
481 |
|
482 |
$t->get_ok( '/cities/' . $city_1->id ) |
483 |
->status_is(200) |
484 |
->json_is( $city_1->to_api ); |
485 |
|
486 |
$t->get_ok( '/cities/' . $city_2->id ) |
487 |
->status_is(200) |
488 |
->json_is( $city_2->to_api ); |
489 |
|
490 |
$schema->storage->txn_rollback; |
491 |
}; |
492 |
|
493 |
subtest 'objects.find helper, embed' => sub { |
494 |
|
495 |
plan tests => 2; |
496 |
|
497 |
my $t = Test::Mojo->new; |
498 |
|
499 |
$schema->storage->txn_begin; |
500 |
|
501 |
my $order = $builder->build_object({ class => 'Koha::Acquisition::Orders' }); |
502 |
|
503 |
$t->get_ok( '/orders/' . $order->ordernumber ) |
504 |
->json_is( $order->to_api( { embed => ( { fund => {} } ) } ) ); |
505 |
|
506 |
$schema->storage->txn_rollback; |
507 |
}; |
452 |
- |
|
|