diff -uNr Catalyst-Runtime-5.80032/t/aggregate/live_component_controller_action_auto.t Catalyst-Runtime-5.80032-jF6kPg/t/aggregate/live_component_controller_action_auto.t --- Catalyst-Runtime-5.80032/t/aggregate/live_component_controller_action_auto.t 2011-02-16 21:28:46.000000000 +0000 +++ Catalyst-Runtime-5.80032-jF6kPg/t/aggregate/live_component_controller_action_auto.t 2011-05-04 16:07:51.000000000 +0000 @@ -10,7 +10,7 @@ BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; } -use Test::More tests => 18*$iters; +use Test::More tests => 27*$iters; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -133,4 +133,58 @@ $expected, 'Executed actions' ); is( $response->content, 'default (auto: 1)', 'Content OK' ); } + + # test detach in auto + { + my @expected = qw[ + TestApp::Controller::Action::Auto::Detach->begin + TestApp::Controller::Action::Auto->auto + TestApp::Controller::Action::Auto::Detach->auto + TestApp::Controller::Root->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/action/auto/detach'), 'auto with detach' ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, 'detach auto', 'Content OK' ); + } + + # test detach in auto forward + { + my @expected = qw[ + TestApp::Controller::Action::Auto::Detach->begin + TestApp::Controller::Action::Auto->auto + TestApp::Controller::Action::Auto::Detach->auto + TestApp::Controller::Action::Auto::Detach->with_forward_detach + TestApp::Controller::Root->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/action/auto/detach?with_forward_detach=1'), 'auto with_forward_detach' ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, 'detach with_forward_detach', 'Content OK' ); + } + + # test detach in auto forward detach action + { + my @expected = qw[ + TestApp::Controller::Action::Auto::Detach->begin + TestApp::Controller::Action::Auto->auto + TestApp::Controller::Action::Auto::Detach->auto + TestApp::Controller::Action::Auto::Detach->with_forward_detach + TestApp::Controller::Action::Auto::Detach->detach_action + TestApp::Controller::Root->end + ]; + + my $expected = join( ", ", @expected ); + + ok( my $response = request('http://localhost/action/auto/detach?with_forward_detach=1&detach_to_action=1'), 'auto with_forward_detach to detach_action' ); + is( $response->header('X-Catalyst-Executed'), + $expected, 'Executed actions' ); + is( $response->content, 'detach action', 'Content OK' ); + } } diff -uNr Catalyst-Runtime-5.80032/t/lib/TestApp/Controller/Action/Auto/Detach.pm Catalyst-Runtime-5.80032-jF6kPg/t/lib/TestApp/Controller/Action/Auto/Detach.pm --- Catalyst-Runtime-5.80032/t/lib/TestApp/Controller/Action/Auto/Detach.pm 1970-01-01 00:00:00.000000000 +0000 +++ Catalyst-Runtime-5.80032-jF6kPg/t/lib/TestApp/Controller/Action/Auto/Detach.pm 2011-05-04 16:16:11.000000000 +0000 @@ -0,0 +1,37 @@ +package TestApp::Controller::Action::Auto::Detach; + +use strict; +use base 'TestApp::Controller::Action'; + +sub auto : Private { + my ( $self, $c ) = @_; + $c->res->body( "detach auto" ); + if ($c->req->param("with_forward_detach")) { + $c->forward("with_forward_detach"); + } else { + $c->detach; + } + return 1; +} + +sub default : Path { + my ( $self, $c ) = @_; + $c->res->body( 'detach default' ); +} + +sub with_forward_detach : Private { + my ($self, $c) = @_; + $c->res->body( "detach with_forward_detach" ); + if ($c->req->param("detach_to_action")) { + $c->detach("detach_action"); + } else { + $c->detach; + } +} + +sub detach_action : Private { + my ($self, $c) = @_; + $c->res->body("detach_action"); +} + +1;