[Catalyst-commits] r11023 - in Catalyst-Runtime/5.80/trunk: lib
t/aggregate
caelum at dev.catalyst.perl.org
caelum at dev.catalyst.perl.org
Sat Aug 1 19:04:11 GMT 2009
Author: caelum
Date: 2009-08-01 19:04:08 +0000 (Sat, 01 Aug 2009)
New Revision: 11023
Modified:
Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_uri_for_action.t
Log:
allow uri_for($controller_instance)
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2009-08-01 02:00:59 UTC (rev 11022)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2009-08-01 19:04:08 UTC (rev 11023)
@@ -1206,6 +1206,12 @@
sub uri_for {
my ( $c, $path, @args ) = @_;
+ if (blessed($path) && $path->isa('Catalyst::Controller')) {
+ $path = $path->path_prefix;
+ $path =~ s{/+\z}{};
+ $path .= '/';
+ }
+
if ( blessed($path) ) { # action object
my $captures = ( scalar @args && ref $args[0] eq 'ARRAY'
? shift(@args)
Modified: Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_uri_for_action.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_uri_for_action.t 2009-08-01 02:00:59 UTC (rev 11022)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/unit_core_uri_for_action.t 2009-08-01 19:04:08 UTC (rev 11023)
@@ -8,7 +8,7 @@
use Test::More;
-plan tests => 29;
+plan tests => 30;
use_ok('TestApp');
@@ -97,6 +97,10 @@
namespace => 'yada',
} );
+is($context->uri_for($context->controller('Action')),
+ "http://127.0.0.1/foo/yada/action/",
+ "uri_for a controller");
+
is($context->uri_for($path_action),
"http://127.0.0.1/foo/action/relative/relative",
"uri_for correct for path action");
More information about the Catalyst-commits
mailing list