[Catalyst-commits] r9508 - in
Catalyst-Controller-DBIC-API/1.001/trunk/t:
lib/RestTest/Controller/API/RPC rpc
lukes at dev.catalyst.perl.org
lukes at dev.catalyst.perl.org
Tue Mar 17 17:58:27 GMT 2009
Author: lukes
Date: 2009-03-17 17:58:27 +0000 (Tue, 17 Mar 2009)
New Revision: 9508
Added:
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Controller/API/RPC/TrackExposed.pm
Catalyst-Controller-DBIC-API/1.001/trunk/t/rpc/list_search_allows.t
Modified:
Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Controller/API/RPC/Track.pm
Log:
failing list_search_allows test
Modified: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Controller/API/RPC/Track.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Controller/API/RPC/Track.pm 2009-03-16 22:13:20 UTC (rev 9507)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Controller/API/RPC/Track.pm 2009-03-17 17:58:27 UTC (rev 9508)
@@ -13,7 +13,8 @@
update_allows => ['title', 'position', { cd => ['*'] }],
list_grouped_by => ['position'],
list_returns => ['position'],
- list_ordered_by => ['position']
+ list_ordered_by => ['position'],
+ list_search_allows => ['title']
);
1;
Added: Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Controller/API/RPC/TrackExposed.pm
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Controller/API/RPC/TrackExposed.pm (rev 0)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/lib/RestTest/Controller/API/RPC/TrackExposed.pm 2009-03-17 17:58:27 UTC (rev 9508)
@@ -0,0 +1,16 @@
+package RestTest::Controller::API::RPC::TrackExposed;
+
+use strict;
+use warnings;
+use base qw/Catalyst::Controller::DBIC::API::RPC/;
+use JSON::Syck;
+
+__PACKAGE__->config
+ ( action => { setup => { PathPart => 'track_exposed', Chained => '/api/rpc/rpc_base' } },
+ class => 'RestTestDB::Track',
+ list_returns => [qw/position title/],
+ list_ordered_by => [qw/position/],
+ list_search_allows => [qw/title/],
+ );
+
+1;
Added: Catalyst-Controller-DBIC-API/1.001/trunk/t/rpc/list_search_allows.t
===================================================================
--- Catalyst-Controller-DBIC-API/1.001/trunk/t/rpc/list_search_allows.t (rev 0)
+++ Catalyst-Controller-DBIC-API/1.001/trunk/t/rpc/list_search_allows.t 2009-03-17 17:58:27 UTC (rev 9508)
@@ -0,0 +1,62 @@
+use 5.6.0;
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+
+my $base = 'http://localhost';
+
+use RestTest;
+use DBICTest;
+use URI;
+use Test::More qw(no_plan);
+use Test::WWW::Mechanize::Catalyst 'RestTest';
+use HTTP::Request::Common;
+use JSON::Syck;
+
+my $mech = Test::WWW::Mechanize::Catalyst->new;
+ok(my $schema = DBICTest->init_schema(), 'got schema');
+
+my $track_list_url = "$base/api/rpc/track_exposed/list";
+my $base_rs = $schema->resultset('Track')->search({}, { select => [qw/title position/], order_by => 'position' });
+
+# test open request
+{
+ my $req = GET( $track_list_url, {
+
+ }, 'Accept' => 'text/x-json' );
+ $mech->request($req);
+ cmp_ok( $mech->status, '==', 200, 'open attempt okay' );
+
+ my @expected_response = map { { $_->get_columns } } $base_rs->all;
+ my $response = JSON::Syck::Load( $mech->content);
+ warn $mech->content;
+ is_deeply( { list => \@expected_response, success => 'true' }, $response, 'correct message returned' );
+}
+
+{
+ my $uri = URI->new( $track_list_url );
+ $uri->query_form({ 'search.position' => 1 });
+ my $req = GET( $uri, {
+
+ }, 'Accept' => 'text/x-json' );
+ $mech->request($req);
+ cmp_ok( $mech->status, '==', 200, 'search on position okay' );
+
+ my @expected_response = map { { $_->get_columns } } $base_rs->search({ position => 1 })->all;
+ my $response = JSON::Syck::Load( $mech->content);
+ is_deeply( { list => \@expected_response, success => 'true' }, $response, 'correct message returned' );
+}
+
+{
+ my $uri = URI->new( $track_list_url );
+ $uri->query_form({ 'search.title' => 'Stripy' });
+ my $req = GET( $uri, {
+
+ }, 'Accept' => 'text/x-json' );
+ $mech->request($req);
+ cmp_ok( $mech->status, '==', 400, 'search on title not okay' );
+
+ warn $mech->content;
+}
More information about the Catalyst-commits
mailing list