[Catalyst-commits] r8444 - in Catalyst-Runtime/5.80/trunk: . lib
lib/Catalyst lib/Catalyst/DispatchType t/aggregate t/lib
t/lib/TestApp/Controller/Action t/lib/TestApp/View
marcus at dev.catalyst.perl.org
marcus at dev.catalyst.perl.org
Wed Sep 24 17:44:46 BST 2008
Author: marcus
Date: 2008-09-24 17:44:46 +0100 (Wed, 24 Sep 2008)
New Revision: 8444
Added:
Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_visit.t
Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Visit.pm
Modified:
Catalyst-Runtime/5.80/trunk/Changes
Catalyst-Runtime/5.80/trunk/Makefile.PL
Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType.pm
Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Chained.pm
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm
Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_go.t
Catalyst-Runtime/5.80/trunk/t/lib/TestApp.pm
Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Go.pm
Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/TestRelative.pm
Catalyst-Runtime/5.80/trunk/t/lib/TestApp/View/Dump.pm
Log:
latest go/visit changes, pod fixes, all tests ok
Modified: Catalyst-Runtime/5.80/trunk/Changes
===================================================================
--- Catalyst-Runtime/5.80/trunk/Changes 2008-09-24 15:53:01 UTC (rev 8443)
+++ Catalyst-Runtime/5.80/trunk/Changes 2008-09-24 16:44:46 UTC (rev 8444)
@@ -10,6 +10,7 @@
$c->req->captures (jhannah)
- List unattached chained actions in Debug mode (Florian Ragwitz).
- Pod formatting fix for Engine::FastCGI (Oleg Kostyuk).
+ - Add visit, a returning ->go
5.7XXXXXX XXXX
- Fix some Win32 test failures
Modified: Catalyst-Runtime/5.80/trunk/Makefile.PL
===================================================================
--- Catalyst-Runtime/5.80/trunk/Makefile.PL 2008-09-24 15:53:01 UTC (rev 8443)
+++ Catalyst-Runtime/5.80/trunk/Makefile.PL 2008-09-24 16:44:46 UTC (rev 8444)
@@ -6,7 +6,7 @@
all_from 'lib/Catalyst/Runtime.pm';
requires 'MooseX::Emulate::Class::Accessor::Fast' => '0.00300';
-requires 'Moose' => '0.51';
+requires 'Moose' => '0.58';
requires 'Carp';
requires 'Class::Accessor::Fast';
requires 'Class::Data::Inheritable';
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Chained.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Chained.pm 2008-09-24 15:53:01 UTC (rev 8443)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Chained.pm 2008-09-24 16:44:46 UTC (rev 8444)
@@ -330,6 +330,14 @@
}
+=head2 $c->expand_action($action)
+
+Return a list of actions that represents a chained action. See
+L<Catalyst::Dispatcher> for more info. You probably want to
+use the expand_action it provides rather than this directly.
+
+=cut
+
sub expand_action {
my ($self, $action) = @_;
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType.pm 2008-09-24 15:53:01 UTC (rev 8443)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType.pm 2008-09-24 16:44:46 UTC (rev 8444)
@@ -58,6 +58,13 @@
sub uri_for_action { }
+=head2 $self->expand_action
+
+Default fallback, returns nothing. See L<Catalyst::Dispatcher> for more info
+about expand_action.
+
+=cut
+
sub expand_action { }
=head1 AUTHORS
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm 2008-09-24 15:53:01 UTC (rev 8443)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Dispatcher.pm 2008-09-24 16:44:46 UTC (rev 8444)
@@ -158,21 +158,40 @@
return $action, \@args;
}
-=head2 $self->go( $c, $command [, \@arguments ] )
+=head2 $self->visit( $c, $command [, \@arguments ] )
Documented in L<Catalyst>
=cut
-sub go {
+sub visit {
my $self = shift;
+ $self->_do_visit('visit', @_);
+}
+
+sub _do_visit {
+ my $self = shift;
+ my $opname = shift;
my ( $c, $command ) = @_;
my ( $action, $args ) = $self->_command2action(@_);
+ my $error = qq/Couldn't $opname("$command"): /;
- unless ($action && defined $action->namespace) {
- my $error =
- qq/Couldn't go to command "$command": /
- . qq/Invalid action or component./;
+ if (!$action) {
+ $error .= qq/Invalid action or component./;
+ }
+ 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./
+ }
+ elsif (!$action->class->can('_DISPATCH')) {
+ $error .= qq/Action cannot _DISPATCH. /
+ .qq/Did you try to $opname() a non-controller action?/;
+ }
+ else {
+ $error = q();
+ }
+
+ if($error) {
$c->error($error);
$c->log->debug($error) if $c->debug;
return 0;
@@ -181,10 +200,21 @@
$action = $self->expand_action($action);
local $c->request->{arguments} = $args;
- $c->namespace($action->namespace);
- $c->action($action);
+ local $c->{namespace} = $action->{'namespace'};
+ local $c->{action} = $action;
+
$self->dispatch($c);
+}
+=head2 $self->go( $c, $command [, \@arguments ] )
+
+Documented in L<Catalyst>
+
+=cut
+
+sub go {
+ my $self = shift;
+ $self->_do_visit('go', @_);
die $Catalyst::GO;
}
@@ -423,6 +453,14 @@
return undef;
}
+=head2 expand_action
+
+expand an action into a full representation of the dispatch.
+mostly useful for chained, other actions will just return a
+single action.
+
+=cut
+
sub expand_action {
my ($self, $action) = @_;
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2008-09-24 15:53:01 UTC (rev 8443)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst.pm 2008-09-24 16:44:46 UTC (rev 8444)
@@ -346,13 +346,33 @@
sub detach { my $c = shift; $c->dispatcher->detach( $c, @_ ) }
+=head2 $c->visit( $action [, \@arguments ] )
+
+=head2 $c->visit( $class, $method, [, \@arguments ] )
+
+Almost the same as C<forward>, but does a full dispatch, instead of just
+calling the new C<$action> / C<$class-E<gt>$method>. This means that C<begin>,
+C<auto> and the method you go to are called, just like a new request.
+
+C<$c-E<gt>stash> is kept unchanged.
+
+In effect, C<visit> allows you to "wrap" another action, just as it
+would have been called by dispatching from a URL, while the analogous
+C<go> allows you to transfer control to another action as if it had
+been reached directly from a URL.
+
+=cut
+
+sub visit { my $c = shift; $c->dispatcher->visit( $c, @_ ) }
+
=head2 $c->go( $action [, \@arguments ] )
=head2 $c->go( $class, $method, [, \@arguments ] )
-Almost the same as C<detach>, but does a full dispatch, instead of just
-calling the new C<$action> / C<$class-E<gt>$method>. This means that C<begin>,
-C<auto> and the method you go to is called, just like a new request.
+Almost the same as C<detach>, but does a full dispatch like C<visit>,
+instead of just calling the new C<$action> /
+C<$class-E<gt>$method>. This means that C<begin>, C<auto> and the
+method you visit are called, just like a new request.
C<$c-E<gt>stash> is kept unchanged.
Modified: Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_go.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_go.t 2008-09-24 15:53:01 UTC (rev 8443)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_go.t 2008-09-24 16:44:46 UTC (rev 8444)
@@ -10,7 +10,7 @@
BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
-use Test::More tests => 50 * $iters;
+use Test::More tests => 54 * $iters;
use Catalyst::Test 'TestApp';
if ( $ENV{CAT_BENCHMARK} ) {
@@ -95,15 +95,34 @@
$expected, 'Executed actions' );
is( $response->content, $Catalyst::GO, "Go died as expected" );
}
-
{
ok(
+ my $response = request('http://localhost/action/go/model'),
+ 'Request with args'
+ );
+ is( $response->content,
+ q[FATAL ERROR: Couldn't go("Model::Foo"): Action cannot _DISPATCH. Did you try to go() a non-controller action?],
+ q[go('Model::...') test]
+ );
+ }
+ {
+ ok(
+ my $response = request('http://localhost/action/go/view'),
+ 'Request with args'
+ );
+ is( $response->content,
+ q[FATAL ERROR: Couldn't go("View::Dump"): Action cannot _DISPATCH. Did you try to go() a non-controller action?],
+ q[go('View::...') test]
+ );
+ }
+ {
+ ok(
my $response =
request('http://localhost/action/go/with_args/old'),
'Request with args'
);
ok( $response->is_success, 'Response Successful 2xx' );
- is( $response->content, 'old' );
+ is( $response->content, 'old', 'go() with args (old)' );
}
{
@@ -113,7 +132,7 @@
'Request with args and method'
);
ok( $response->is_success, 'Response Successful 2xx' );
- is( $response->content, 'new' );
+ is( $response->content, 'new', 'go() with args (new)' );
}
# test go with embedded args
@@ -124,7 +143,7 @@
'Request'
);
ok( $response->is_success, 'Response Successful 2xx' );
- is( $response->content, 'ok' );
+ is( $response->content, 'ok', 'go() with args_embed_relative' );
}
{
@@ -134,7 +153,7 @@
'Request'
);
ok( $response->is_success, 'Response Successful 2xx' );
- is( $response->content, 'ok' );
+ is( $response->content, 'ok', 'go() with args_embed_absolute' );
}
{
my @expected = qw[
@@ -221,7 +240,10 @@
'Request'
);
ok( !$response->is_success, 'Response Fails' );
- is( $response->content, q(FATAL ERROR: Couldn't go to command "TestApp": Invalid action or component.), 'Error message' );
+ is( $response->content,
+ q(FATAL ERROR: Couldn't go("TestApp"): Action has no namespace: cannot go() to a plain method or component, must be a :Action or some sort.),
+ 'Error message'
+ );
}
{
Added: Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_visit.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_visit.t (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_visit.t 2008-09-24 16:44:46 UTC (rev 8444)
@@ -0,0 +1,289 @@
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/../lib";
+
+our $iters;
+
+BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
+
+use Test::More tests => 54 * $iters;
+use Catalyst::Test 'TestApp';
+
+if ( $ENV{CAT_BENCHMARK} ) {
+ require Benchmark;
+ Benchmark::timethis( $iters, \&run_tests );
+}
+else {
+ for ( 1 .. $iters ) {
+ run_tests();
+ }
+}
+
+sub run_tests {
+ {
+ # Test visit to global private action
+ ok( my $response = request('http://localhost/action/visit/global'),
+ 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content_type, 'text/plain', 'Response Content-Type' );
+ is( $response->header('X-Catalyst-Action'),
+ 'action/visit/global', 'Main Class Action' );
+ }
+
+ {
+ my @expected = qw[
+ TestApp::Controller::Action::Visit->one
+ TestApp::Controller::Action::Visit->two
+ TestApp::Controller::Action::Visit->three
+ TestApp::Controller::Action::Visit->four
+ TestApp::Controller::Action::Visit->five
+ TestApp::View::Dump::Request->process
+ TestApp->end
+ TestApp->end
+ TestApp->end
+ TestApp->end
+ TestApp->end
+ ];
+
+ @expected = map { /Action/ ? (_begin($_), $_) : ($_) } @expected;
+ my $expected = join( ", ", @expected );
+
+ # Test visit to chain of actions.
+ ok( my $response = request('http://localhost/action/visit/one'),
+ 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content_type, 'text/plain', 'Response Content-Type' );
+ is( $response->header('X-Catalyst-Action'),
+ 'action/visit/one', 'Test Action' );
+ is(
+ $response->header('X-Test-Class'),
+ 'TestApp::Controller::Action::Visit',
+ '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'
+ );
+ }
+ {
+ my @expected = qw[
+ TestApp::Controller::Action::Visit->visit_die
+ TestApp::Controller::Action::Visit->args
+ TestApp->end
+ TestApp->end
+ ];
+
+ @expected = map { /Action/ ? (_begin($_), $_) : ($_) } @expected;
+ my $expected = join( ", ", @expected );
+
+ ok( my $response = request('http://localhost/action/visit/visit_die'),
+ 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content_type, 'text/plain', 'Response Content-Type' );
+ is( $response->header('X-Catalyst-Action'),
+ 'action/visit/visit_die', 'Test Action'
+ );
+ is(
+ $response->header('X-Test-Class'),
+ 'TestApp::Controller::Action::Visit',
+ 'Test Class'
+ );
+ is( $response->header('X-Catalyst-Executed'),
+ $expected, 'Executed actions' );
+ is( $response->content, "visit() doesn't die", "Visit does not die" );
+ }
+ {
+ ok(
+ my $response = request('http://localhost/action/visit/model'),
+ 'Request with args'
+ );
+ is( $response->content,
+ q[FATAL ERROR: Couldn't visit("Model::Foo"): Action cannot _DISPATCH. Did you try to visit() a non-controller action?]
+ );
+ }
+ {
+ ok(
+ my $response = request('http://localhost/action/visit/view'),
+ 'Request with args'
+ );
+ is( $response->content,
+ q[FATAL ERROR: Couldn't visit("View::Dump"): Action cannot _DISPATCH. Did you try to visit() a non-controller action?]
+ );
+ }
+ {
+ ok(
+ my $response =
+ request('http://localhost/action/visit/with_args/old'),
+ 'Request with args'
+ );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content, 'old', 'visit() with args (old)' );
+ }
+
+ {
+ ok(
+ my $response = request(
+ 'http://localhost/action/visit/with_method_and_args/new'),
+ 'Request with args and method'
+ );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content, 'new', 'visit() with args (new)' );
+ }
+
+ # test visit with embedded args
+ {
+ ok(
+ my $response =
+ request('http://localhost/action/visit/args_embed_relative'),
+ 'Request'
+ );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content, 'ok', 'visit() with args_embed_relative' );
+ }
+
+ {
+ ok(
+ my $response =
+ request('http://localhost/action/visit/args_embed_absolute'),
+ 'Request'
+ );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content, 'ok', 'visit() with args_embed_absolute' );
+ }
+ {
+ my @expected = qw[
+ TestApp::Controller::Action::TestRelative->relative_visit
+ TestApp::Controller::Action::Visit->one
+ TestApp::Controller::Action::Visit->two
+ TestApp::Controller::Action::Visit->three
+ TestApp::Controller::Action::Visit->four
+ TestApp::Controller::Action::Visit->five
+ TestApp::View::Dump::Request->process
+ TestApp->end
+ TestApp->end
+ TestApp->end
+ TestApp->end
+ TestApp->end
+ TestApp->end
+ ];
+
+ @expected = map { /Action/ ? (_begin($_), $_) : ($_) } @expected;
+ my $expected = join( ", ", @expected );
+
+ # Test visit to chain of actions.
+ ok( my $response = request('http://localhost/action/relative/relative_visit'),
+ 'Request' );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content_type, 'text/plain', 'Response Content-Type' );
+ is( $response->header('X-Catalyst-Action'),
+ 'action/relative/relative_visit', 'Test Action' );
+ is(
+ $response->header('X-Test-Class'),
+ 'TestApp::Controller::Action::Visit',
+ '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'
+ );
+ }
+ {
+ my @expected = qw[
+ TestApp::Controller::Action::TestRelative->relative_visit_two
+ TestApp::Controller::Action::Visit->one
+ TestApp::Controller::Action::Visit->two
+ TestApp::Controller::Action::Visit->three
+ TestApp::Controller::Action::Visit->four
+ TestApp::Controller::Action::Visit->five
+ TestApp::View::Dump::Request->process
+ TestApp->end
+ TestApp->end
+ TestApp->end
+ TestApp->end
+ TestApp->end
+ TestApp->end
+ ];
+
+ @expected = map { /Action/ ? (_begin($_), $_) : ($_) } @expected;
+ my $expected = join( ", ", @expected );
+
+ # Test visit to chain of actions.
+ ok(
+ my $response =
+ request('http://localhost/action/relative/relative_visit_two'),
+ 'Request'
+ );
+ ok( $response->is_success, 'Response Successful 2xx' );
+ is( $response->content_type, 'text/plain', 'Response Content-Type' );
+ is(
+ $response->header('X-Catalyst-Action'),
+ 'action/relative/relative_visit_two',
+ 'Test Action'
+ );
+ is(
+ $response->header('X-Test-Class'),
+ 'TestApp::Controller::Action::Visit',
+ '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'
+ );
+ }
+
+ # test class visit -- MUST FAIL!
+ {
+ ok(
+ my $response = request(
+ 'http://localhost/action/visit/class_visit_test_action'),
+ 'Request'
+ );
+ 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.],
+ "Cannot visit app namespace"
+ );
+ }
+
+ {
+ my @expected = qw[
+ TestApp::Controller::Action::Visit->begin
+ TestApp::Controller::Action::Visit->visit_chained
+ TestApp::Controller::Action::Chained->begin
+ TestApp::Controller::Action::Chained->foo
+ TestApp::Controller::Action::Chained::Foo->spoon
+ TestApp::Controller::Action::Chained->end
+ TestApp->end
+ ];
+
+ my $expected = join( ", ", @expected );
+
+ ok( my $response = request('http://localhost/action/visit/visit_chained'), 'visit to chained + subcontroller endpoint' );
+ is( $response->header('X-Catalyst-Executed'),
+ $expected, 'Executed actions' );
+ is( $response->content, '; 1', 'Content OK' );
+ }
+
+}
+
+
+
+sub _begin {
+ local $_ = shift;
+ s/->(.*)$/->begin/;
+ return $_;
+}
+
Modified: Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Go.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Go.pm 2008-09-24 15:53:01 UTC (rev 8443)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Go.pm 2008-09-24 16:44:46 UTC (rev 8444)
@@ -25,7 +25,7 @@
sub five : Local {
my ( $self, $c ) = @_;
- $c->go('View::Dump::Request');
+ $c->forward('View::Dump::Request');
}
sub inheritance : Local {
@@ -66,6 +66,18 @@
$c->go('/action/chained/foo/spoon',[1]);
}
+sub view : Local {
+ my ( $self, $c, $val ) = @_;
+ eval { $c->go('View::Dump') };
+ $c->res->body( $@ ? $@ : "go() did not die" );
+}
+
+sub model : Local {
+ my ( $self, $c, $val ) = @_;
+ eval { $c->go('Model::Foo') };
+ $c->res->body( $@ ? $@ : "go() did not die" );
+}
+
sub args_embed_relative : Local {
my ( $self, $c ) = @_;
$c->go('embed/ok');
Modified: Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/TestRelative.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/TestRelative.pm 2008-09-24 15:53:01 UTC (rev 8443)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/TestRelative.pm 2008-09-24 16:44:46 UTC (rev 8444)
@@ -26,4 +26,15 @@
my ( $self, $c ) = @_;
$c->go( 'TestApp::Controller::Action::Go', 'one' );
}
+
+sub relative_visit : Local {
+ my ( $self, $c ) = @_;
+ $c->visit('/action/visit/one');
+}
+
+sub relative_visit_two : Local {
+ my ( $self, $c ) = @_;
+ $c->visit( 'TestApp::Controller::Action::Visit', 'one' );
+}
+
1;
Added: Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Visit.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Visit.pm (rev 0)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Visit.pm 2008-09-24 16:44:46 UTC (rev 8444)
@@ -0,0 +1,101 @@
+package TestApp::Controller::Action::Visit;
+
+use strict;
+use base 'TestApp::Controller::Action';
+
+sub one : Local {
+ my ( $self, $c ) = @_;
+ $c->visit('two');
+}
+
+sub two : Private {
+ my ( $self, $c ) = @_;
+ $c->visit('three');
+}
+
+sub three : Local {
+ my ( $self, $c ) = @_;
+ $c->visit( $self, 'four' );
+}
+
+sub four : Private {
+ my ( $self, $c ) = @_;
+ $c->visit('/action/visit/five');
+}
+
+sub five : Local {
+ my ( $self, $c ) = @_;
+ $c->forward('View::Dump::Request');
+}
+
+sub inheritance : Local {
+ my ( $self, $c ) = @_;
+ $c->visit('/action/inheritance/a/b/default');
+}
+
+sub global : Local {
+ my ( $self, $c ) = @_;
+ $c->visit('/global_action');
+}
+
+sub with_args : Local {
+ my ( $self, $c, $arg ) = @_;
+ $c->visit( 'args', [$arg] );
+}
+
+sub with_method_and_args : Local {
+ my ( $self, $c, $arg ) = @_;
+ $c->visit( qw/TestApp::Controller::Action::Visit args/, [$arg] );
+}
+
+sub args : Local {
+ my ( $self, $c, $val ) = @_;
+ die "passed argument does not match args" unless $val eq $c->req->args->[0];
+ $c->res->body($val);
+}
+
+sub visit_die : Local {
+ my ( $self, $c, $val ) = @_;
+ eval { $c->visit( 'args', [qq/new/] ) };
+ $c->res->body( $@ ? $@ : "visit() doesn't die" );
+}
+
+sub visit_chained : Local {
+ my ( $self, $c, $val ) = @_;
+ $c->visit('/action/chained/foo/spoon',[1]);
+}
+
+sub view : Local {
+ my ( $self, $c, $val ) = @_;
+ eval { $c->visit('View::Dump') };
+ $c->res->body( $@ ? $@ : "visit() did not die" );
+}
+
+sub model : Local {
+ my ( $self, $c, $val ) = @_;
+ eval { $c->visit('Model::Foo') };
+ $c->res->body( $@ ? $@ : "visit() did not die" );
+}
+
+sub args_embed_relative : Local {
+ my ( $self, $c ) = @_;
+ $c->visit('embed/ok');
+}
+
+sub args_embed_absolute : Local {
+ my ( $self, $c ) = @_;
+ $c->visit('/action/visit/embed/ok');
+}
+
+sub embed : Local {
+ my ( $self, $c, $ok ) = @_;
+ $ok ||= 'not ok';
+ $c->res->body($ok);
+}
+
+sub class_visit_test_action : Local {
+ my ( $self, $c ) = @_;
+ $c->visit(qw/TestApp class_visit_test_method/);
+}
+
+1;
Modified: Catalyst-Runtime/5.80/trunk/t/lib/TestApp/View/Dump.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp/View/Dump.pm 2008-09-24 15:53:01 UTC (rev 8443)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp/View/Dump.pm 2008-09-24 16:44:46 UTC (rev 8444)
@@ -1,7 +1,7 @@
package TestApp::View::Dump;
use strict;
-use base 'Catalyst::Base';
+use base 'Catalyst::View';
use Data::Dumper ();
use Scalar::Util qw(weaken);
Modified: Catalyst-Runtime/5.80/trunk/t/lib/TestApp.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp.pm 2008-09-24 15:53:01 UTC (rev 8443)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp.pm 2008-09-24 16:44:46 UTC (rev 8444)
@@ -77,6 +77,11 @@
$c->response->headers->header( 'X-Class-Go-Test-Method' => 1 );
}
+sub class_visit_test_method :Private {
+ my ( $self, $c ) = @_;
+ $c->response->headers->header( 'X-Class-Visit-Test-Method' => 1 );
+}
+
sub loop_test : Local {
my ( $self, $c ) = @_;
More information about the Catalyst-commits
mailing list