From: Tomas Doran Date: Sat, 21 Mar 2009 18:04:06 +0000 (+0000) Subject: Much cleaner. The visit class test wasn't actually testing visiting the class, so... X-Git-Tag: 5.80001~57^2~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=382d317c39473fe7792a08d071f00883f50ed73b Much cleaner. The visit class test wasn't actually testing visiting the class, so I fixed that and made the English in the error message more correct (IMO) --- diff --git a/lib/Catalyst/Dispatcher.pm b/lib/Catalyst/Dispatcher.pm index 840342b..68fe551 100644 --- a/lib/Catalyst/Dispatcher.pm +++ b/lib/Catalyst/Dispatcher.pm @@ -190,7 +190,7 @@ sub _do_visit { } elsif (!defined $action->namespace) { $error .= qq/Action has no namespace: cannot $opname() to a plain / - .qq/method or component, must be a :Action or some sort./ + .qq/method or component, must be an :Action of some sort./ } elsif (!$action->class->can('_DISPATCH')) { $error .= qq/Action cannot _DISPATCH. / @@ -320,14 +320,8 @@ sub _invoke_as_component { my $class = $self->_find_component_class( $c, $component ) || return 0; - ### XXX FIXME - Horrible hack to get proper action objects for - ### controller paths.. - if ($class =~ /::C(ontroller)?::/) { - my $possible_path = $class . '/' . $method; - $possible_path =~ s/.+::C(ontroller)?:://; - $possible_path =~ s|::|/|g; - $possible_path =~ tr/A-Z/a-z/; - my $possible_action = $self->_invoke_as_path( $c, '/' . $possible_path ); + if (my $code = $component_instance->can('action_for')) { + my $possible_action = $component_instance->$code($method); return $possible_action if $possible_action; } diff --git a/t/aggregate/live_component_controller_action_visit.t b/t/aggregate/live_component_controller_action_visit.t index febf935..468496b 100644 --- a/t/aggregate/live_component_controller_action_visit.t +++ b/t/aggregate/live_component_controller_action_visit.t @@ -253,7 +253,7 @@ sub run_tests { ); ok( !$response->is_success, 'Response Fails' ); is( $response->content, - q{FATAL ERROR: Couldn't visit("TestApp"): Action has no namespace: cannot visit() to a plain method or component, must be a :Action or some sort.}, + q{FATAL ERROR: Couldn't visit("TestApp"): Action has no namespace: cannot visit() to a plain method or component, must be an :Action of some sort.}, "Cannot visit app namespace" ); } diff --git a/t/lib/TestApp/Controller/Action/Visit.pm b/t/lib/TestApp/Controller/Action/Visit.pm index 9f8f9a5..0ddaacb 100644 --- a/t/lib/TestApp/Controller/Action/Visit.pm +++ b/t/lib/TestApp/Controller/Action/Visit.pm @@ -98,7 +98,7 @@ sub embed : Local { sub class_visit_test_action : Local { my ( $self, $c ) = @_; - $c->visit(qw/TestApp class_visit_test_method/); + $c->visit(qw/TestApp/); } 1;