From: John Napiorkowski Date: Wed, 25 Mar 2015 14:54:44 +0000 (-0500) Subject: test cases for the args0 issue X-Git-Tag: 5.90085~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=67b8d82923e00a64e872a93685e0e19d41168451;hp=6a02419e70368bbe76c20ae488e316d0115de928 test cases for the args0 issue --- diff --git a/t/args0_bug.t b/t/args0_bug.t index 86f9dd6..4f6fd48 100644 --- a/t/args0_bug.t +++ b/t/args0_bug.t @@ -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__ + diff --git a/t/lib/TestApp/Controller/HTTPMethods.pm b/t/lib/TestApp/Controller/HTTPMethods.pm index 2f7476d..5d42858 100644 --- a/t/lib/TestApp/Controller/HTTPMethods.pm +++ b/t/lib/TestApp/Controller/HTTPMethods.pm @@ -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;