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

(-)a/t/Koha/REST/Plugin/Pagination.t (-7 / +15 lines)
Lines 66-72 get '/pagination_headers_without_page_size' => sub { Link Here
66
66
67
get '/pagination_headers_without_page' => sub {
67
get '/pagination_headers_without_page' => sub {
68
    my $c = shift;
68
    my $c = shift;
69
    $c->add_pagination_headers({ total => 10, params => { _per_page => 4, firstname => 'Jonathan' } });
69
    $c->add_pagination_headers({ total => 10, params => { _per_page => 3, firstname => 'Jonathan' } });
70
    $c->render( json => { ok => 1 }, status => 200 );
70
    $c->render( json => { ok => 1 }, status => 200 );
71
};
71
};
72
72
Lines 79-85 use t::lib::Mocks; Link Here
79
79
80
subtest 'add_pagination_headers() tests' => sub {
80
subtest 'add_pagination_headers() tests' => sub {
81
81
82
    plan tests => 64;
82
    plan tests => 75;
83
83
84
    my $t = Test::Mojo->new;
84
    my $t = Test::Mojo->new;
85
85
Lines 151-160 subtest 'add_pagination_headers() tests' => sub { Link Here
151
151
152
    $t->get_ok('/pagination_headers_without_page')
152
    $t->get_ok('/pagination_headers_without_page')
153
      ->status_is( 200 )
153
      ->status_is( 200 )
154
      ->header_is( 'X-Total-Count' => undef, 'X-Total-Count header absent' )
154
      ->header_is( 'X-Total-Count' => 10, 'X-Total-Count header present, even without page param' )
155
      ->header_is( 'Link'          => undef, 'Link header absent' );
155
      ->header_unlike( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="prev",/, 'First page, no previous' )
156
156
      ->header_unlike( 'Link' => qr/<http:\/\/.*\?.*page=1.*>; rel="prev",/, 'First page, no previous' )
157
157
      ->header_unlike( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="prev",/, 'First page, no previous' )
158
      ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="next",/ )
159
      ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=3.*>; rel="next",/ )
160
      ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="next",/ )
161
      ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="first",/ )
162
      ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=1.*>; rel="first",/ )
163
      ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="first",/ )
164
      ->header_like( 'Link' => qr/<http:\/\/.*\?.*per_page=3.*>; rel="last"/ )
165
      ->header_like( 'Link' => qr/<http:\/\/.*\?.*page=4.*>; rel="last"/ )
166
      ->header_like( 'Link' => qr/<http:\/\/.*\?.*firstname=Jonathan.*>; rel="last"/ );
158
};
167
};
159
168
160
subtest 'dbic_merge_pagination() tests' => sub {
169
subtest 'dbic_merge_pagination() tests' => sub {
161
- 

Return to bug 26143