From: Brian Cassidy Date: Fri, 18 Jul 2008 00:01:14 +0000 (+0000) Subject: Fix regression for regexp fallback in model(), view() and controller() X-Git-Tag: 5.7099_04~44 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=fb5f42422b1ef1a4cc64ddfd83836c8c1d89bb2c Fix regression for regexp fallback in model(), view() and controller() --- diff --git a/Changes b/Changes index c6b929d..03a5cb9 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ # This file documents the revision history for Perl extension Catalyst. +5.7xxxxxx XXXX + - Fix regression for regexp fallback in model(), view() and controller() + 5.7099_02 2008-07-16 19:10:00 - Added PathPrefix attribute - Removed Catalyst::Build; we've long since moved to Module::Install diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index c20ceca..c84253d 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -452,7 +452,7 @@ sub _comp_search_prefixes { # regexp fallback $query = qr/$name/i; - @result = grep { $eligible{ $_ } =~ m{$query} } keys %eligible; + @result = map { $c->components->{ $_ } } grep { $eligible{ $_ } =~ m{$query} } keys %eligible; # don't warn if we didn't find any results, it just might not exist if( @result ) { diff --git a/t/unit_core_mvc.t b/t/unit_core_mvc.t index dc080f9..74b4ecf 100644 --- a/t/unit_core_mvc.t +++ b/t/unit_core_mvc.t @@ -1,4 +1,4 @@ -use Test::More tests => 37; +use Test::More tests => 40; use strict; use warnings; @@ -107,6 +107,20 @@ is ( MyApp->model , 'MyApp::Model::M', 'default_model in class method ok'); is_deeply( [ MyApp->view( qr{^V[ie]+w$} ) ], [ 'MyApp::V::View' ], 'regexp view ok' ); is_deeply( [ MyApp->controller( qr{Dummy\::Model$} ) ], [ 'MyApp::Controller::Model::Dummy::Model' ], 'regexp controller ok' ); is_deeply( [ MyApp->model( qr{Dum{2}y} ) ], [ 'MyApp::Model::Dummy::Model' ], 'regexp model ok' ); + + # ACCEPT_CONTEXT w/ qr{} + is_deeply( [ MyApp->model( qr{Test} ) ], [ MyApp->components->{'MyApp::Model::Test::Object'} ], 'Object returned' ); + + { + my $warnings = 0; + no warnings 'redefine'; + local *Catalyst::Log::warn = sub { $warnings++ }; + + # ACCEPT_CONTEXT w/ regexp fallback + is_deeply( [ MyApp->model( 'Test' ) ], [ MyApp->components->{'MyApp::Model::Test::Object'} ], 'Object returned' ); + ok( $warnings, 'regexp fallback warnings' ); + } + } {