X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Frest%2Flist.t;h=c1aa7b23decb2531bb6cf6bd2755401094eb44eb;hb=e17f1f8e991b57bf9f7f23547c0c9af8b3012569;hp=ab2aa4ec47471064df7dea0daf3bd70f2e7e4a2b;hpb=11ba2ccc06f22b028f66fdfcad72ce3903345374;p=catagits%2FCatalyst-Controller-DBIC-API.git diff --git a/t/rest/list.t b/t/rest/list.t index ab2aa4e..c1aa7b2 100644 --- a/t/rest/list.t +++ b/t/rest/list.t @@ -143,7 +143,7 @@ my $track_list_url = "$base/api/rest/track"; $mech->request($req); cmp_ok( $mech->status, '==', 400, 'attempt with nonexisting relationship fails' ); my $response = JSON::Any->Load( $mech->content); - is_deeply( $response->{messages}, ["track is neither a relationship nor a column\n"], 'correct error message returned' ); + is_deeply( $response->{messages}, ['track is neither a relationship nor a column'], 'correct error message returned' ); } { @@ -156,4 +156,19 @@ my $track_list_url = "$base/api/rest/track"; is_deeply( $response->{messages}, ['a database error has occured.'], 'correct error message returned' ); } +{ + my $uri = URI->new( $artist_list_url ); + $uri->query_form({ 'search.cds.tracks.title.like' => 'Boring%' }); + my $req = GET( $uri, 'Accept' => 'text/x-json' ); + $mech->request($req); + cmp_ok( $mech->status, '==', 200, 'attempt with sql function ok' ); + my $response = JSON::Any->Load( $mech->content); + my @expected_response = map { { $_->get_columns } } $schema->resultset('Artist')->search({ + 'tracks.title' => { 'like' => 'Boring%' }, + }, { + join => { cds => 'tracks' }, + })->all; + is_deeply( $response, { list => \@expected_response, success => 'true' }, 'correct data returned for search with sql function' ); +} + done_testing();