X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-DBIC-API.git;a=blobdiff_plain;f=t%2Frest%2Flist.t;h=7d8c68f02b33930f957942569fdcea575dcc19b1;hp=205c330562c69930c74f9add9c340f926bca92c6;hb=4a805f62625bb1e4152fd2ef25169ac6683ca611;hpb=dde946747a25b53c539c4ff1043c1f7601364d11 diff --git a/t/rest/list.t b/t/rest/list.t index 205c330..7d8c68f 100644 --- a/t/rest/list.t +++ b/t/rest/list.t @@ -21,6 +21,8 @@ ok(my $schema = DBICTest->init_schema(), 'got schema'); 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 { @@ -104,4 +106,34 @@ my $producer_list_url = "$base/api/rest/producer"; is_deeply( $response, { list => \@expected_response, success => 'true' }, 'correct data returned for class with setup_list_method specified' ); } +{ + my $uri = URI->new( $cd_list_url ); + $uri->query_form({ 'search.tracks.position' => '1', 'search.artist.name' => 'Caterwauler McCrae' }); + my $req = GET( $uri, 'Accept' => 'text/x-json' ); + $mech->request($req); + cmp_ok( $mech->status, '==', 200, 'search multiple params request okay' ); + my $response = JSON::Any->Load( $mech->content); + my @expected_response = map { { $_->get_columns } } $schema->resultset('CD')->search({ + 'artist.name' => 'Caterwauler McCrae', + 'tracks.position' => 1, + }, { + join => [qw/ artist tracks /], + })->all; + 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();