View::TT, added tests from dwc
[catagits/Catalyst-View-TT.git] / t / lib / TestApp.pm
1 package TestApp;
2
3 use strict;
4 use warnings;
5
6 use Catalyst; # qw/-Debug/;
7
8 our $VERSION = '0.01';
9
10 __PACKAGE__->config(
11     name                  => 'TestApp',
12     default_message       => 'hi',
13     default_view          => 'Pkgconfig',
14     'View::TT::Appconfig' => {
15         PRE_CHOMP          => 1,
16         POST_CHOMP         => 1,
17         TEMPLATE_EXTENSION => '.tt',
18     },
19 );
20
21 __PACKAGE__->setup;
22
23 sub default : Private {
24     my ($self, $c) = @_;
25
26     $c->response->redirect($c->uri_for('test'));
27 }
28
29 sub test : Local {
30     my ($self, $c) = @_;
31
32     $c->stash->{message} = ($c->request->param('message') || $c->config->{default_message});
33 }
34
35 sub end : Private {
36     my ($self, $c) = @_;
37
38     return 1 if $c->response->status =~ /^3\d\d$/;
39     return 1 if $c->response->body;
40
41     my $view = 'View::TT::' . ($c->request->param('view') || $c->config->{default_view});
42     $c->forward($view);
43 }
44
45 1;