[Catalyst-commits] r12060 - in Catalyst-Runtime/5.80/trunk/t: aggregate lib/TestApp/Controller/Action/Chained

gshank at dev.catalyst.perl.org gshank at dev.catalyst.perl.org
Fri Nov 27 22:43:12 GMT 2009


Author: gshank
Date: 2009-11-27 22:43:11 +0000 (Fri, 27 Nov 2009)
New Revision: 12060

Added:
   Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Chained/CaptureArgs.pm
Modified:
   Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_chained.t
Log:
testcase for Chained bug - dispatches to wrong action


Modified: Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_chained.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_chained.t	2009-11-27 16:31:32 UTC (rev 12059)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_chained.t	2009-11-27 22:43:11 UTC (rev 12060)
@@ -908,6 +908,26 @@
         is( $response->content => 'a; anchor.html', 'Content OK' );
     }
 
+    # CaptureArgs(1) PathPart('...') should win over CaptureArgs(2) PathPart('')
+    {
+        my @expected = qw[
+          TestApp::Controller::Action::Chained->begin
+          TestApp::Controller::Action::Chained::CaptureArgs->base
+          TestApp::Controller::Action::Chained::CaptureArgs->one_arg
+          TestApp::Controller::Action::Chained::CaptureArgs->edit_one_arg
+          TestApp::Controller::Action::Chained::CaptureArgs->end
+        ];
+
+        my $expected = join( ", ", @expected );
+
+        # should dispatch to /base/one_args/edit_one_arg
+        ok( my $response = request('http://localhost/captureargs/one/edit'),
+            'Correct arg order ran' );
+        is( $response->header('X-Catalyst-Executed'),
+            $expected, 'Executed actions' );
+        is( $response->content, 'base; one_arg; edit_one_arg', 'Content OK' );
+    }
+
     #
     #   Args(0) should win over Args() if we actually have no arguments.
     {

Added: Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Chained/CaptureArgs.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Chained/CaptureArgs.pm	                        (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Chained/CaptureArgs.pm	2009-11-27 22:43:11 UTC (rev 12060)
@@ -0,0 +1,60 @@
+package TestApp::Controller::Action::Chained::CaptureArgs;
+use warnings;
+use strict;
+
+use base qw( Catalyst::Controller );
+
+#
+#   This controller builds two patterns of URI:
+#      /captureargs/*/*
+#      /captureargs/*/*/edit
+#      /captureargs/*
+#      /captureargs/*/edit
+#   It will output the arguments they got passed to @_ after the
+#   context object. 
+#   /captureargs/one/edit should not dispatch to
+#   /captureargs/*/*
+
+sub base  :Chained('/') PathPart('captureargs') CaptureArgs(0) {
+    my ( $self, $c, $arg ) = @_;
+    push @{ $c->stash->{ passed_args } }, 'base';
+}
+
+sub two_args :Chained('base') PathPart('') CaptureArgs(2) {
+    my ( $self, $c, $arg1, $arg2 ) = @_;
+    push @{ $c->stash->{ passed_args } }, 'two_args', $arg1, $arg2;
+}
+
+sub one_arg :Chained('base') ParthPart('') CaptureArgs(1) {
+    my ( $self, $c, $arg ) = @_;
+    push @{ $c->stash->{ passed_args } }, 'one_arg', $arg;
+}
+
+sub edit_two_args  :Chained('two_args') PathPart('edit') Args(0) {
+    my ( $self, $c ) = @_;
+    push @{ $c->stash->{ passed_args } }, 'edit_two_args';
+}
+
+sub edit_one_arg :Chained('one_arg') PathPart('edit') Args(0) {
+    my ( $self, $c ) = @_;
+    push @{ $c->stash->{ passed_args } }, 'edit_one_arg';
+}
+
+sub view_two_args :Chained('two_args') PathPart('') Args(0) {
+    my ( $self, $c ) = @_;
+    push @{ $c->stash->{ passed_args } }, 'view_two_args';
+}
+
+sub view_one_arg :Chained('one_arg') PathPart('') Args(0) {
+    my ( $self, $c ) = @_;
+    push @{ $c->stash->{ passed_args } }, 'view_one_arg';
+}
+
+
+sub end : Private {
+    my ( $self, $c ) = @_;
+    no warnings 'uninitialized';
+    $c->response->body( join '; ', @{ $c->stash->{ passed_args } } );
+}
+
+1;




More information about the Catalyst-commits mailing list