fixed static configured page attribute not being used (RT#56226)
Alexander Hartmaier [Wed, 11 Aug 2010 08:53:25 +0000 (10:53 +0200)]
Changes
lib/Catalyst/Controller/DBIC/API/RequestArguments.pm
t/lib/RestTest/Controller/API/REST/Track.pm
t/rest/list.t

diff --git a/Changes b/Changes
index 3b67140..5270c1f 100644 (file)
--- 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
 
index e920857..f490eed 100644 (file)
@@ -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,
         };
index f8b15b8..33362e0 100644 (file)
@@ -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;
index 6d73b59..7d8c68f 100644 (file)
@@ -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();