patch to make prepare_parameters not be both a builder and a preparer
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / Root.pm
CommitLineData
32d5a0c5 1package TestApp::Controller::Root;
5ab21903 2use strict;
3use warnings;
32d5a0c5 4use base 'Catalyst::Controller';
5
6__PACKAGE__->config->{namespace} = '';
7
81e75875 8sub chain_root_index : Chained('/') PathPart('') Args(0) { }
9
53119b78 10sub zero : Path('0') {
11 my ( $self, $c ) = @_;
12 $c->res->header( 'X-Test-Class' => ref($self) );
13 $c->response->content_type('text/plain; charset=utf-8');
14 $c->forward('TestApp::View::Dump::Request');
15}
16
bcc7361a 17sub zerobody : Local {
18 my ($self, $c) = @_;
19 $c->res->body('0');
20}
21
22sub emptybody : Local {
23 my ($self, $c) = @_;
24 $c->res->body('');
25}
26
19c01ee1 27sub localregex : LocalRegex('^localregex$') {
28 my ( $self, $c ) = @_;
29 $c->res->header( 'X-Test-Class' => ref($self) );
30 $c->response->content_type('text/plain; charset=utf-8');
31 $c->forward('TestApp::View::Dump::Request');
32}
33
a202886b 34sub index : Private {
35 my ( $self, $c ) = @_;
36 $c->res->body('root index');
37}
38
39sub global_action : Private {
40 my ( $self, $c ) = @_;
41 $c->forward('TestApp::View::Dump::Request');
42}
43
44sub class_forward_test_method :Private {
45 my ( $self, $c ) = @_;
46 $c->response->headers->header( 'X-Class-Forward-Test-Method' => 1 );
47}
48
49sub loop_test : Local {
50 my ( $self, $c ) = @_;
51
52 for( 1..1001 ) {
53 $c->forward( 'class_forward_test_method' );
54 }
55}
56
57sub recursion_test : Local {
58 my ( $self, $c ) = @_;
421ae538 59 no warnings 'recursion';
a202886b 60 $c->forward( 'recursion_test' );
61}
62
f23f1634 63sub base_href_test : Local {
64 my ( $self, $c ) = @_;
65
66 my $body = <<"EndOfBody";
67<html>
68 <head>
69 <base href="http://www.example.com/">
70 </head>
71 <body>
72 </body>
73</html>
74EndOfBody
75
76 $c->response->body($body);
77}
78
ffb43803 79sub body_semipredicate : Local {
80 my ($self, $c) = @_;
81 $c->res->body; # Old code tests length($c->res->body), which causes the value to be built (undef), which causes the predicate
82 $c->res->status( $c->res->has_body ? 500 : 200 ); # to return the wrong thing, resulting in a 500.
83 $c->res->body('Body');
84}
85
d67d5f87 86
87sub test_redirect :Global {
88 my ($self, $c) = @_;
89 # Don't set content_type
90 # Don't set body
91 $c->res->redirect('/go_here');
92}
93
94sub test_redirect_with_contenttype :Global {
95 my ($self, $c) = @_;
96 # set content_type but don't set body
97 $c->res->content_type('image/jpeg');
98 $c->res->redirect('/go_here');
99}
100
101sub test_redirect_with_content :Global {
102 my ($self, $c) = @_;
103 $c->res->content_type('text/plain');
104 $c->res->body('Please kind sir, I beg you to go to /go_here.');
105 $c->res->redirect('/go_here');
106}
107
a0a66cb8 108sub end : Private {
109 my ($self,$c) = @_;
110}
111
32d5a0c5 1121;