Write more tests.
Tomas Doran [Wed, 7 Jul 2010 21:25:19 +0000 (22:25 +0100)]
For foo_XXXX methods being dispatched as proper actions (via ->forward)
if they have action objects

t/catalyst-action-rest-action-dispatch.t
t/lib/Test/Action/Class/Sub.pm [new file with mode: 0644]
t/lib/Test/Catalyst/Action/REST/Controller/Actions.pm

index a092690..348966b 100644 (file)
@@ -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 (file)
index 0000000..372fcfc
--- /dev/null
@@ -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;
index 33b363a..2e91a35 100644 (file)
@@ -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');
 }