From: Alexander Hartmaier Date: Fri, 20 Aug 2010 15:06:38 +0000 (+0200) Subject: added test for searching with sql functions X-Git-Tag: 2.002003~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-DBIC-API.git;a=commitdiff_plain;h=ff26acf7da32b80ffef5f814cbb2391eed4ea50d added test for searching with sql functions --- diff --git a/t/rest/list.t b/t/rest/list.t index 783aa4c..c1aa7b2 100644 --- a/t/rest/list.t +++ b/t/rest/list.t @@ -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();