test inheritance of builtin actions in mainapp.
[catagits/Catalyst-Runtime.git] / t / live / lib / TestApp.pm
1 package TestApp;
2
3 use strict;
4 use Catalyst qw/Test::Errors Test::Headers Test::Plugin/;
5 use Catalyst::Utils;
6
7 our $VERSION = '0.01';
8
9 TestApp->config( name => 'TestApp', root => '/some/dir' );
10
11 TestApp->setup;
12
13 sub index : Private {
14     my ( $self, $c ) = @_;
15     $c->res->body( 'root index' );
16 }
17
18 sub global_action : Private {
19     my ( $self, $c ) = @_;
20     $c->forward('TestApp::View::Dump::Request');
21 }
22
23
24 sub execute {
25     my $c      = shift;
26     my $class  = ref( $c->component( $_[0] ) ) || $_[0];
27     my $action = "$_[1]";
28
29     my $method;
30
31     if ( $action =~ /->(\w+)$/ ) {
32         $method = $1;
33     }
34     elsif ( $action =~ /\/(\w+)$/ ) {
35         $method = $1;
36     }
37     elsif ( $action =~ /^(\w+)$/ ) {
38         $method = $action;
39     }
40
41
42     if ( $class && $method && $method !~ /^_/ ) {
43         my $executed = sprintf( "%s->%s", $class, $method );
44         my @executed = $c->response->headers->header('X-Catalyst-Executed');
45         push @executed, $executed;
46         $c->response->headers->header(
47             'X-Catalyst-Executed' => join ', ',
48             @executed
49         );
50     }
51
52     return $c->SUPER::execute(@_);
53 }
54
55 1;