[Catalyst-commits] r9540 - in
Catalyst-Runtime/5.80/branches/add_captures_to_visit:
lib/Catalyst t/aggregate t/lib/TestApp/Controller/Action
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Sat Mar 21 15:04:33 GMT 2009
Author: t0m
Date: 2009-03-21 15:04:33 +0000 (Sat, 21 Mar 2009)
New Revision: 9540
Modified:
Catalyst-Runtime/5.80/branches/add_captures_to_visit/lib/Catalyst/Dispatcher.pm
Catalyst-Runtime/5.80/branches/add_captures_to_visit/t/aggregate/live_component_controller_action_visit.t
Catalyst-Runtime/5.80/branches/add_captures_to_visit/t/lib/TestApp/Controller/Action/Visit.pm
Log:
Make CaptureArgs get passed, this makes the test less fail, but not perfect yet. Also, needs docs..
Modified: Catalyst-Runtime/5.80/branches/add_captures_to_visit/lib/Catalyst/Dispatcher.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/add_captures_to_visit/lib/Catalyst/Dispatcher.pm 2009-03-21 15:03:21 UTC (rev 9539)
+++ Catalyst-Runtime/5.80/branches/add_captures_to_visit/lib/Catalyst/Dispatcher.pm 2009-03-21 15:04:33 UTC (rev 9540)
@@ -119,7 +119,8 @@
}
# $self->_command2action( $c, $command [, \@arguments ] )
-# Search for an action, from the command and returns C<($action, $args)> on
+# $self->_command2action( $c, $command [, \@captures, \@arguments ] )
+# Search for an action, from the command and returns C<($action, $args, $captures)> on
# success. Returns C<(0)> on error.
sub _command2action {
@@ -130,8 +131,12 @@
return 0;
}
- my @args;
+ my (@args, @captures);
+ if ( ref( $extra_params[-2] ) eq 'ARRAY' ) {
+ @captures = @{ pop @extra_params };
+ }
+
if ( ref( $extra_params[-1] ) eq 'ARRAY' ) {
@args = @{ pop @extra_params }
} else {
@@ -158,7 +163,7 @@
$action = $self->_invoke_as_component( $c, $command, $method );
}
- return $action, \@args;
+ return $action, \@args, \@captures;
}
=head2 $self->visit( $c, $command [, \@arguments ] )
@@ -176,7 +181,7 @@
my $self = shift;
my $opname = shift;
my ( $c, $command ) = @_;
- my ( $action, $args ) = $self->_command2action(@_);
+ my ( $action, $args, $captures ) = $self->_command2action(@_);
my $error = qq/Couldn't $opname("$command"): /;
if (!$action) {
@@ -204,6 +209,7 @@
$action = $self->expand_action($action);
local $c->request->{arguments} = $args;
+ local $c->request->{captures} = $captures;
local $c->{namespace} = $action->{'namespace'};
local $c->{action} = $action;
@@ -237,7 +243,7 @@
my $self = shift;
my $opname = shift;
my ( $c, $command ) = @_;
- my ( $action, $args ) = $self->_command2action(@_);
+ my ( $action, $args, $captures ) = $self->_command2action(@_);
if (!$action) {
my $error .= qq/Couldn't $opname to command "$command": /
Modified: Catalyst-Runtime/5.80/branches/add_captures_to_visit/t/aggregate/live_component_controller_action_visit.t
===================================================================
--- Catalyst-Runtime/5.80/branches/add_captures_to_visit/t/aggregate/live_component_controller_action_visit.t 2009-03-21 15:03:21 UTC (rev 9539)
+++ Catalyst-Runtime/5.80/branches/add_captures_to_visit/t/aggregate/live_component_controller_action_visit.t 2009-03-21 15:04:33 UTC (rev 9540)
@@ -253,7 +253,7 @@
);
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 a :Action or some sort.},
"Cannot visit app namespace"
);
}
@@ -272,11 +272,12 @@
my $expected = join( ", ", @expected );
for my $i ( 1..3 ) {
- ok( my $response = request("http://localhost/action/visit/visit_chained/$i"),
+ ok( my $response = request("http://localhost/action/visit/visit_chained/$i/becomescapture/arg1/arg2"),
"visit to chained + subcontroller endpoint for $i" );
is( $response->header('X-Catalyst-Executed'),
$expected, "Executed actions for $i" );
- is( $response->content, "; $i", "Content OK for $i" );
+ is( $response->content, "arg1, arg2; becomescapture",
+ "Content OK for $i" );
}
}
Modified: Catalyst-Runtime/5.80/branches/add_captures_to_visit/t/lib/TestApp/Controller/Action/Visit.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/add_captures_to_visit/t/lib/TestApp/Controller/Action/Visit.pm 2009-03-21 15:03:21 UTC (rev 9539)
+++ Catalyst-Runtime/5.80/branches/add_captures_to_visit/t/lib/TestApp/Controller/Action/Visit.pm 2009-03-21 15:04:33 UTC (rev 9540)
@@ -61,10 +61,11 @@
}
sub visit_chained : Local {
- my ( $self, $c, $val ) = @_;
- $val eq 1 ? $c->visit( '/action/chained/foo/spoon', [$val] )
- : $val eq 2 ? $c->visit( qw/ Action::Chained::Foo spoon /, [$val] )
- : $c->visit( $c->controller('Action::Chained::Foo')->action_for('spoon'), [$val] )
+ my ( $self, $c, $val, $capture, @args ) = @_;
+ my @cap_and_args = ([$capture], [@args]);
+ $val eq 1 ? $c->visit( '/action/chained/foo/spoon', @cap_and_args)
+ : $val eq 2 ? $c->visit( qw/ Action::Chained::Foo spoon /, @cap_and_args)
+ : $c->visit( $c->controller('Action::Chained::Foo')->action_for('spoon'), @cap_and_args)
}
sub view : Local {
More information about the Catalyst-commits
mailing list