X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Flib%2FTestApp.pm;h=594dfa3a4c0b4a2526db7beaf088f3ad693fa2ed;hp=e7f2ae281f1073d2edcfe7838f0487943d1c3fc4;hb=66741f94ac93b7ba0989db3556d0e3fe36c1be87;hpb=dd4e6fd2152eea9f5b0c1f559575ced7684ef257 diff --git a/t/lib/TestApp.pm b/t/lib/TestApp.pm index e7f2ae2..594dfa3 100644 --- a/t/lib/TestApp.pm +++ b/t/lib/TestApp.pm @@ -1,37 +1,57 @@ package TestApp; use strict; -use Catalyst qw[Test::Errors Test::Headers]; +use Catalyst qw/Test::Errors Test::Headers Test::Plugin/; +use Catalyst::Utils; our $VERSION = '0.01'; -TestApp->config( - name => 'TestApp', - root => '/Users/chansen/src/MyApp/root', -); +TestApp->config( name => 'TestApp', root => '/some/dir' ); TestApp->setup; -#sub execute { return shift->NEXT::execute(@_); } # does not work, bug? +sub index : Private { + my ( $self, $c ) = @_; + $c->res->body('root index'); +} + +sub global_action : Private { + my ( $self, $c ) = @_; + $c->forward('TestApp::View::Dump::Request'); +} sub execute { - my $c = shift; - my $class = ref( $c->component($_[0]) ) || $_[0]; - my $action = $c->actions->{reverse}->{"$_[1]"} || "$_[1]"; + my $c = shift; + my $class = ref( $c->component( $_[0] ) ) || $_[0]; + my $action = "$_[1]"; my $method; - if ( $action =~ /->(\w+)$/ ) { - $method = $1; + if ( $action =~ /->(\w+)$/ ) { + $method = $1; } - elsif ( $action =~ /\/(\w+)$/ ) { - $method = $1; + elsif ( $action =~ /\/(\w+)$/ ) { + $method = $1; + } + elsif ( $action =~ /^(\w+)$/ ) { + $method = $action; } - my $executed = sprintf( "%s->%s", $class, $method ); + if ( $class && $method && $method !~ /^_/ ) { + my $executed = sprintf( "%s->%s", $class, $method ); + my @executed = $c->response->headers->header('X-Catalyst-Executed'); + push @executed, $executed; + $c->response->headers->header( + 'X-Catalyst-Executed' => join ', ', + @executed + ); + } - $c->response->headers->push_header( 'X-Catalyst-Executed' => $executed ); return $c->SUPER::execute(@_); } +{ + no warnings 'redefine'; + sub Catalyst::Log::error { } +} 1;