From: Andy Grundman Date: Thu, 15 Sep 2005 15:59:59 +0000 (+0000) Subject: Backported [1133] dispatcher fix to trunk X-Git-Tag: 5.7099_04~1243 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=6f2a2de7197da36913c829e5491bd0ddebc5e335 Backported [1133] dispatcher fix to trunk --- diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 3d43f9c..cb01934 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -209,6 +209,7 @@ sub get_action { push @results, [$result] if $result; my $visitor = Tree::Simple::Visitor::FindByPath->new; + SEARCH: for my $part ( split '/', $namespace ) { $visitor->setSearchPath($part); $parent->accept($visitor); @@ -216,7 +217,12 @@ sub get_action { my $uid = $child->getUID if $child; my $match = $c->actions->{private}->{$uid}->{$action} if $uid; push @results, [$match] if $match; - $parent = $child if $child; + if ($child) { + $parent = $child; + } + else { + last SEARCH; + } } } diff --git a/t/component/controller/action/default.t b/t/component/controller/action/default.t index 65563cf..b41893b 100644 --- a/t/component/controller/action/default.t +++ b/t/component/controller/action/default.t @@ -6,7 +6,7 @@ use warnings; use FindBin; use lib "$FindBin::Bin/../../../lib"; -use Test::More tests=>7 ; +use Test::More tests=>9 ; use Catalyst::Test 'TestApp'; @@ -26,4 +26,7 @@ use Catalyst::Test 'TestApp'; is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Default', 'Test Class' ); is( $response->header('X-Catalyst-Executed'), $expected, 'Executed actions' ); like( $response->content, qr/^bless\( .* 'Catalyst::Request' \)$/s, 'Content is a serialized Catalyst::Request' ); + + ok( $response = request('http://localhost/foo/bar/action'), 'Request' ); + is( $response->code, 404, 'Invalid URI returned 404' ); }