From: John Napiorkowski Date: Tue, 24 Mar 2015 15:30:21 +0000 (-0500) Subject: arg0 bug X-Git-Tag: 5.90085~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=6a02419e70368bbe76c20ae488e316d0115de928;hp=4f04ee56cd0b7d1156d00b7b9771b39a6949002e arg0 bug --- diff --git a/t/args0_bug.t b/t/args0_bug.t new file mode 100644 index 0000000..86f9dd6 --- /dev/null +++ b/t/args0_bug.t @@ -0,0 +1,64 @@ +use warnings; +use strict; +use Test::More; + +{ + package MyApp::Controller::Root; + $INC{'MyApp/Controller/Root.pm'} = __FILE__; + + use Moose; + use MooseX::MethodAttributes; + + extends 'Catalyst::Controller'; + + 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') } + + MyApp::Controller::Root->config(namespace=>''); + + package MyApp; + use Catalyst; + + MyApp->setup; +} + +=over + +[debug] Loaded Chained actions: +.-----------------------------------------+---------------------------------------------------. +| Path Spec | Private | ++-----------------------------------------+---------------------------------------------------+ +| /chain_base/*/* | /chain_base (1) | +| | => /chained_one_args_0 (1) | +| /chain_base/*/* | /chain_base (1) | +| | => /chained_one_args_1 (1) | +| /chain_base/* | /chain_base (1) | +| | => /chained_zero_args_0 (0) | +| /chain_base/* | /chain_base (1) | +| | => /chained_zero_args_1 (0) | +'-----------------------------------------+---------------------------------------------------' + +=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'"; +} + +{ + # 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'"; +} + +done_testing;