From: Alexander Hartmaier Date: Wed, 11 Aug 2010 08:53:25 +0000 (+0200) Subject: fixed static configured page attribute not being used (RT#56226) X-Git-Tag: 2.002003~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-DBIC-API.git;a=commitdiff_plain;h=4a805f62625bb1e4152fd2ef25169ac6683ca611 fixed static configured page attribute not being used (RT#56226) --- diff --git a/Changes b/Changes index 3b67140..5270c1f 100644 --- a/Changes +++ b/Changes @@ -6,6 +6,7 @@ Revision history for Catalyst-Controller-DBIC-API: {{ $dist->version }} - Fixed RPC delete_bulk not working at all - Added REST and RPC update_bulk tests - Removed useless RPC index action +- Fixed static configured page attribute not being used (RT#56226) 2.002002 2010-08-03 14:40:50 Europe/Vienna diff --git a/lib/Catalyst/Controller/DBIC/API/RequestArguments.pm b/lib/Catalyst/Controller/DBIC/API/RequestArguments.pm index e920857..f490eed 100644 --- a/lib/Catalyst/Controller/DBIC/API/RequestArguments.pm +++ b/lib/Catalyst/Controller/DBIC/API/RequestArguments.pm @@ -574,6 +574,7 @@ This builder method generates the search attributes as => $self->as || ((scalar(@{$static->as})) ? $static->as : undef), prefetch => $self->prefetch || $static->prefetch || undef, rows => $self->count || $static->count, + page => $static->page, offset => $self->offset, join => $self->build_joins, }; diff --git a/t/lib/RestTest/Controller/API/REST/Track.pm b/t/lib/RestTest/Controller/API/REST/Track.pm index f8b15b8..33362e0 100644 --- a/t/lib/RestTest/Controller/API/REST/Track.pm +++ b/t/lib/RestTest/Controller/API/REST/Track.pm @@ -10,6 +10,8 @@ __PACKAGE__->config create_requires => ['cd', 'title' ], create_allows => ['cd', 'title', 'position' ], update_allows => ['title', 'position', { cd => ['*'] }], + page => 1, + count => 10, ); 1; diff --git a/t/rest/list.t b/t/rest/list.t index 6d73b59..7d8c68f 100644 --- a/t/rest/list.t +++ b/t/rest/list.t @@ -22,6 +22,7 @@ my $artist_list_url = "$base/api/rest/artist"; my $filtered_artist_list_url = "$base/api/rest/bound_artist"; my $producer_list_url = "$base/api/rest/producer"; my $cd_list_url = "$base/api/rest/cd"; +my $track_list_url = "$base/api/rest/track"; # test open request { @@ -121,4 +122,18 @@ my $cd_list_url = "$base/api/rest/cd"; is_deeply( $response, { list => \@expected_response, success => 'true' }, 'correct data returned for multiple search params' ); } +# page specified in controller config (RT#56226) +{ + my $uri = URI->new( $track_list_url ); + $uri->query_form(); + my $req = GET( $uri, 'Accept' => 'text/x-json' ); + $mech->request($req); + cmp_ok( $mech->status, '==', 200, 'get first page ok' ); + my $response = JSON::Any->Load( $mech->content); + my @expected_response = map { { $_->get_columns } } $schema->resultset('Track')->search(undef, { + page => 1, + })->all; + is_deeply( $response, { list => \@expected_response, success => 'true', totalcount => 15 }, 'correct data returned for static configured paging' ); +} + done_testing();