Lines 72-83
get '/biblios' => sub {
Link Here
|
72 |
} |
72 |
} |
73 |
}); |
73 |
}); |
74 |
my $biblios = $c->objects->search($biblios_set); |
74 |
my $biblios = $c->objects->search($biblios_set); |
75 |
|
75 |
$c->render( status => 200, json => {count => scalar(@$biblios), biblios => $biblios} ); |
76 |
$c->render( status => 200, json => {count => scalar(@$biblios)} ); |
|
|
77 |
}; |
76 |
}; |
78 |
|
77 |
|
|
|
78 |
|
79 |
# The tests |
79 |
# The tests |
80 |
use Test::More tests => 8; |
80 |
use Test::More tests => 9; |
81 |
use Test::Mojo; |
81 |
use Test::Mojo; |
82 |
|
82 |
|
83 |
use t::lib::TestBuilder; |
83 |
use t::lib::TestBuilder; |
Lines 316-323
subtest 'object.search helper with all query methods' => sub {
Link Here
|
316 |
|
316 |
|
317 |
$schema->storage->txn_begin; |
317 |
$schema->storage->txn_begin; |
318 |
|
318 |
|
319 |
my $patron1 = $builder->build_object( { class => "Koha::Patrons" , value => {cardnumber => 'cardpatron1', firstname=>'patron1'} } ); |
319 |
my $patron1 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron1'} } ); |
320 |
my $patron2 = $builder->build_object( { class => "Koha::Patrons" , value => {cardnumber => 'cardpatron2', firstname=>'patron2'} } ); |
320 |
my $patron2 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron2'} } ); |
321 |
my $biblio1 = $builder->build_sample_biblio; |
321 |
my $biblio1 = $builder->build_sample_biblio; |
322 |
my $biblio2 = $builder->build_sample_biblio; |
322 |
my $biblio2 = $builder->build_sample_biblio; |
323 |
my $biblio3 = $builder->build_sample_biblio; |
323 |
my $biblio3 = $builder->build_sample_biblio; |
Lines 335-338
subtest 'object.search helper with all query methods' => sub {
Link Here
|
335 |
->json_is('/count' => 0, 'there shouldn\'t be biblios where suggester has patron1 fistname and patron2 id'); |
335 |
->json_is('/count' => 0, 'there shouldn\'t be biblios where suggester has patron1 fistname and patron2 id'); |
336 |
|
336 |
|
337 |
$schema->storage->txn_rollback; |
337 |
$schema->storage->txn_rollback; |
338 |
}; |
338 |
}; |
|
|
339 |
|
340 |
subtest 'object.search helper order by embedded columns' => sub { |
341 |
plan tests => 3; |
342 |
|
343 |
my $patron1 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron1'} } ); |
344 |
my $patron2 = $builder->build_object( { class => "Koha::Patrons" , value => {firstname=>'patron2'} } ); |
345 |
my $biblio1 = $builder->build_sample_biblio; |
346 |
my $biblio2 = $builder->build_sample_biblio; |
347 |
my $suggestion1 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron1->borrowernumber, biblionumber => $biblio1->biblionumber} } ); |
348 |
my $suggestion2 = $builder->build_object( { class => "Koha::Suggestions", value => { suggestedby => $patron2->borrowernumber, biblionumber => $biblio2->biblionumber} } ); |
349 |
|
350 |
$t->get_ok('/biblios?_order_by=-suggestions.suggester.firstname' => json => [{"me.biblio_id" => $biblio1->biblionumber}, {"me.biblio_id" => $biblio2->biblionumber}]) |
351 |
->json_is('/biblios/0/biblio_id' => $biblio2->biblionumber, 'Biblio 2 should be first') |
352 |
->json_is('/biblios/1/biblio_id' => $biblio1->biblionumber, 'Biblio 1 should be second'); |
353 |
|
354 |
$schema->storage->txn_begin; |
355 |
} |
339 |
- |
|
|