View | Details | Raw Unified | Return to bug 26636
Collapse All | Expand All

(-)a/t/db_dependent/Koha/REST/Plugin/Objects.t (-3 / +58 lines)
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 397-404 subtest 'object.search helper with all query methods' => sub { Link Here
397
};
412
};
398
413
399
subtest 'object.search helper order by embedded columns' => sub {
414
subtest 'object.search helper order by embedded columns' => sub {
415
400
    plan tests => 3;
416
    plan tests => 3;
401
417
418
    $schema->storage->txn_begin;
419
402
    my $patron1 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron1'} } );
420
    my $patron1 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron1'} } );
403
    my $patron2 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron2'} } );
421
    my $patron2 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron2'} } );
404
    my $biblio1 = $builder->build_sample_biblio;
422
    my $biblio1 = $builder->build_sample_biblio;
Lines 411-415 subtest 'object.search helper order by embedded columns' => sub { Link Here
411
      ->json_is('/biblios/0/biblio_id' => $biblio2->biblionumber, 'Biblio 2 should be first')
429
      ->json_is('/biblios/0/biblio_id' => $biblio2->biblionumber, 'Biblio 2 should be first')
412
      ->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second');
430
      ->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second');
413
431
432
    $schema->storage->txn_rollback;
433
};
434
435
subtest 'objects.find helper' => sub {
436
437
    plan tests => 6;
438
439
    my $t = Test::Mojo->new;
440
414
    $schema->storage->txn_begin;
441
    $schema->storage->txn_begin;
415
}
442
443
    my $city_1 = $builder->build_object( { class => 'Koha::Cities' } );
444
    my $city_2 = $builder->build_object( { class => 'Koha::Cities' } );
445
446
    $t->get_ok( '/cities/' . $city_1->id )
447
      ->status_is(200)
448
      ->json_is( $city_1->to_api );
449
450
    $t->get_ok( '/cities/' . $city_2->id )
451
      ->status_is(200)
452
      ->json_is( $city_2->to_api );
453
454
    $schema->storage->txn_rollback;
455
};
456
457
subtest 'objects.find helper, embed' => sub {
458
459
    plan tests => 2;
460
461
    my $t = Test::Mojo->new;
462
463
    $schema->storage->txn_begin;
464
465
    my $order = $builder->build_object({ class => 'Koha::Acquisition::Orders' });
466
467
    $t->get_ok( '/orders/' . $order->ordernumber )
468
      ->json_is( $order->to_api( { embed => ( { fund => {} } ) } ) );
469
470
    $schema->storage->txn_rollback;
471
};
416
- 

Return to bug 26636