From: Tomas Doran Date: Wed, 7 Jul 2010 21:25:19 +0000 (+0100) Subject: Write more tests. X-Git-Tag: 0.86~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-REST.git;a=commitdiff_plain;h=5213846dc53c8fdcb6de11243fad7e40378624e7 Write more tests. For foo_XXXX methods being dispatched as proper actions (via ->forward) if they have action objects --- diff --git a/t/catalyst-action-rest-action-dispatch.t b/t/catalyst-action-rest-action-dispatch.t index a092690..348966b 100644 --- a/t/catalyst-action-rest-action-dispatch.t +++ b/t/catalyst-action-rest-action-dispatch.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 21; +use Test::More 0.88; use FindBin; use lib ( "$FindBin::Bin/lib", "$FindBin::Bin/../lib" ); @@ -42,3 +42,21 @@ foreach my $method (qw(GET DELETE POST PUT OPTIONS)) { ); } +my $res = request( + $t->put( + url => '/actions/test', + data => '', + ) +); +is( + $res->header('Using-Action'), + 'STATION', + "went through action for dispatching to PUT" +); +is( + $res->header('Using-Sub-Action'), + 'MOO', + "went through sub action for dispatching to PUT" +); + +done_testing; diff --git a/t/lib/Test/Action/Class/Sub.pm b/t/lib/Test/Action/Class/Sub.pm new file mode 100644 index 0000000..372fcfc --- /dev/null +++ b/t/lib/Test/Action/Class/Sub.pm @@ -0,0 +1,13 @@ +package Test::Action::Class::Sub; +use Moose; + +extends 'Test::Action::Class'; + +before execute => sub { + my ($self, $controller, $c, @args) = @_; + $c->response->header( 'Using-Sub-Action' => 'MOO' ); +}; + +no Moose; + +1; diff --git a/t/lib/Test/Catalyst/Action/REST/Controller/Actions.pm b/t/lib/Test/Catalyst/Action/REST/Controller/Actions.pm index 33b363a..2e91a35 100644 --- a/t/lib/Test/Catalyst/Action/REST/Controller/Actions.pm +++ b/t/lib/Test/Catalyst/Action/REST/Controller/Actions.pm @@ -23,7 +23,7 @@ sub test_POST : Action { $c->res->body('POST'); } -sub test_PUT :ActionClass('+Test::Action::Class') { +sub test_PUT :ActionClass('+Test::Action::Class::Sub') { my ( $self, $c ) = @_; $c->res->body('PUT'); }