On Wed, Jun 24, 2009 at 3:00 PM, Fitz Elliott<[email protected]> wrote: > Hey Amiri, > >> Now for the problem. When I go to test this: >> >> my $mech = Test::WWW::Mechanize::Catalyst->new; >> ok(my $schema = DBICTest->init_schema(), 'got schema'); >> >> my $req = GET("http://localhost/api/rest/artist/list", { >> }, 'Accept' => 'text/x-json' ); >> $mech->request($req); >> cmp_ok( $mech->status, '==', 200, 'open attempt okay' ); > > > I just finished building some code around C::C::DBIC::API and ran into > something similar. I'm assuming in this test that you are trying to get a > list of all artists. If so, you should make a GET request against > http://localhost/api/rest/artist. In a REST controller, artist/list would > be asking for the artist whose id is 'list'. C::C::DBIC::API also doesn't > support GET on an individual object out of the box, but it is easy to add. > Just add > > sub object_GET :Private {} > > in RestTest::ControllerBase::REST. The rest of the code is already there to > retrieve the object and serialize it.
As Fitz has said above - if you want to use REST then you have to make the GET request to just /api/rest/artist. However if you would prefer to to the url /api/rest/artist/list then that's more RPC style and so you'd have to be subclassing Catalyst::Controller::DBIC::API::RPC. I'm interested in the '//localhost/api/rest/artist/api/rest/artist/object' weirdness. Is that specific to running under Test::WWW::Mechanize::Catalyst? Maybe try starting a server in debug mode and then specify CATALYST_SERVER=http://localhost:3000 before running the test to see how that's getting dispatched. Cheers, Luke. _______________________________________________ List: [email protected] Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
