Link Here
|
24 |
|
24 |
|
25 |
plugin 'Koha::REST::Plugin::Pagination'; |
25 |
plugin 'Koha::REST::Plugin::Pagination'; |
26 |
|
26 |
|
|
|
27 |
# For add_pagination_headers() |
27 |
|
28 |
|
28 |
get '/empty' => sub { |
29 |
get '/empty' => sub { |
29 |
my $c = shift; |
30 |
my $c = shift; |
Link Here
|
48 |
$c->render( json => { ok => 1 }, status => 200 ); |
49 |
$c->render( json => { ok => 1 }, status => 200 ); |
49 |
}; |
50 |
}; |
50 |
|
51 |
|
|
|
52 |
# For dbic_merge_pagination |
53 |
|
54 |
get '/dbic_merge_pagination' => sub { |
55 |
my $c = shift; |
56 |
my $filter = { firstname => 'Kyle', surname => 'Hall' }; |
57 |
$filter = $c->dbic_merge_pagination({ filter => $filter, params => { _page => 1, _per_page => 3 } }); |
58 |
$c->render( json => $filter, status => 200 ); |
59 |
}; |
60 |
|
51 |
# The tests |
61 |
# The tests |
52 |
|
62 |
|
53 |
use Test::More tests => 1; |
63 |
use Test::More tests => 2; |
54 |
use Test::Mojo; |
64 |
use Test::Mojo; |
55 |
|
65 |
|
56 |
subtest 'add_pagination_headers() tests' => sub { |
66 |
subtest 'add_pagination_headers() tests' => sub { |
Link Here
|
108 |
->header_like( 'Link' => qr/<http:\/\/.*\?.*_page=4.*>; rel="last"/ ) |
118 |
->header_like( 'Link' => qr/<http:\/\/.*\?.*_page=4.*>; rel="last"/ ) |
109 |
->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="last"/ ); |
119 |
->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="last"/ ); |
110 |
}; |
120 |
}; |
111 |
- |
121 |
|
|
|
122 |
subtest 'dbic_merge_pagination() tests' => sub { |
123 |
|
124 |
plan tests => 3; |
125 |
|
126 |
my $t = Test::Mojo->new; |
127 |
|
128 |
$t->get_ok('/dbic_merge_pagination') |
129 |
->status_is(200) |
130 |
->json_is({ firstname => 'Kyle', surname => 'Hall', page => 1, rows => 3 }); |
131 |
}; |