test cases for the args0 issue
John Napiorkowski [Wed, 25 Mar 2015 14:54:44 +0000 (09:54 -0500)]
t/args0_bug.t
t/lib/TestApp/Controller/HTTPMethods.pm

index 86f9dd6..4f6fd48 100644 (file)
@@ -13,12 +13,12 @@ use Test::More;
 
   sub chain_base :Chained(/) CaptureArgs(1) { }
 
-    sub chained_zero_args_0 : Chained(chain_base) PathPart('') Args(0) { $_[1]->res->body('chained_zero_args_0') }
-    sub chained_zero_args_1 : Chained(chain_base) PathPart('') Args(0) { $_[1]->res->body('chained_zero_args_1') }
-
     sub chained_one_args_0  : Chained(chain_base) PathPart('') Args(1) { $_[1]->res->body('chained_one_args_0') }
     sub chained_one_args_1  : Chained(chain_base) PathPart('') Args(1) { $_[1]->res->body('chained_one_args_1') }
 
+    sub chained_zero_args_0 : Chained(chain_base) PathPart('') Args(0) { $_[1]->res->body('chained_zero_args_0') }
+    sub chained_zero_args_1 : Chained(chain_base) PathPart('') Args(0) { $_[1]->res->body('chained_zero_args_1') }
+
   MyApp::Controller::Root->config(namespace=>'');
 
   package MyApp;
@@ -46,19 +46,17 @@ use Test::More;
 =cut
 
 use Catalyst::Test 'MyApp';
-
 {
-    # Generally if more than one action can match and the path length is equal, we expect
-    # the dispatcher to just take the first one.  So this works as expected.
-    my $res = request '/chain_base/capturearg/arg';
-    is $res->content, 'chained_one_args_1', "request '/chain_base/capturearg/arg'";
+   my $res = request '/chain_base/capturearg/arg';
+  is $res->content, 'chained_one_args_1', "request '/chain_base/capturearg/arg'";
 }
 
 {
-    # However this doesn't pass :(  For some reason when Args(0), we take the last one that
-    # matches...
     my $res = request '/chain_base/capturearg';
-    is $res->content, 'chained_zero_args_1', "request '/chained_one_args_0/capturearg/arg'";
+    is $res->content, 'chained_zero_args_1', "request '/chain_base/capturearg'";
 }
 
 done_testing;
+
+__END__
+
index 2f7476d..5d42858 100644 (file)
@@ -80,6 +80,10 @@ sub delete2 :Chained('post_or_delete') PathPart('') Args(0) DELETE {
 
 sub check_default :Chained('base') CaptureArgs(0) { }
 
+sub chain_default :Chained('check_default') PathPart('') Args(0) {
+    pop->res->body('chain_default');
+}
+
 sub default_get :Chained('check_default') PathPart('') Args(0) GET {
     pop->res->body('get3');
 }
@@ -88,8 +92,6 @@ sub default_post :Chained('check_default') PathPart('') Args(0) POST {
     pop->res->body('post3');
 }
 
-sub chain_default :Chained('check_default') PathPart('') Args(0) {
-    pop->res->body('chain_default');
-}
+
 
 __PACKAGE__->meta->make_immutable;