Commit | Line | Data |
ae0e35ee |
1 | package TestApp::Controller::Action::Visit; |
2 | |
3 | use strict; |
4 | use base 'TestApp::Controller::Action'; |
5 | |
6 | sub one : Local { |
7 | my ( $self, $c ) = @_; |
8 | $c->visit('two'); |
9 | } |
10 | |
11 | sub two : Private { |
12 | my ( $self, $c ) = @_; |
13 | $c->visit('three'); |
14 | } |
15 | |
16 | sub three : Local { |
17 | my ( $self, $c ) = @_; |
18 | $c->visit( $self, 'four' ); |
19 | } |
20 | |
21 | sub four : Private { |
22 | my ( $self, $c ) = @_; |
23 | $c->visit('/action/visit/five'); |
24 | } |
25 | |
26 | sub five : Local { |
27 | my ( $self, $c ) = @_; |
28 | $c->forward('View::Dump::Request'); |
29 | } |
30 | |
31 | sub inheritance : Local { |
32 | my ( $self, $c ) = @_; |
33 | $c->visit('/action/inheritance/a/b/default'); |
34 | } |
35 | |
36 | sub global : Local { |
37 | my ( $self, $c ) = @_; |
38 | $c->visit('/global_action'); |
39 | } |
40 | |
41 | sub with_args : Local { |
42 | my ( $self, $c, $arg ) = @_; |
43 | $c->visit( 'args', [$arg] ); |
44 | } |
45 | |
46 | sub with_method_and_args : Local { |
47 | my ( $self, $c, $arg ) = @_; |
48 | $c->visit( qw/TestApp::Controller::Action::Visit args/, [$arg] ); |
49 | } |
50 | |
51 | sub args : Local { |
52 | my ( $self, $c, $val ) = @_; |
53 | die "passed argument does not match args" unless $val eq $c->req->args->[0]; |
54 | $c->res->body($val); |
55 | } |
56 | |
57 | sub visit_die : Local { |
58 | my ( $self, $c, $val ) = @_; |
59 | eval { $c->visit( 'args', [qq/new/] ) }; |
60 | $c->res->body( $@ ? $@ : "visit() doesn't die" ); |
61 | } |
62 | |
63 | sub visit_chained : Local { |
64 | my ( $self, $c, $val ) = @_; |
62605319 |
65 | $val eq 1 ? $c->visit( '/action/chained/foo/spoon', [$val] ) |
66 | : $val eq 2 ? $c->visit( qw/ Action::Chained::Foo spoon /, [$val] ) |
67 | : $c->visit( $c->controller('Action::Chained::Foo')->action_for('spoon'), [$val] ) |
ae0e35ee |
68 | } |
69 | |
70 | sub view : Local { |
71 | my ( $self, $c, $val ) = @_; |
72 | eval { $c->visit('View::Dump') }; |
73 | $c->res->body( $@ ? $@ : "visit() did not die" ); |
74 | } |
75 | |
76 | sub model : Local { |
77 | my ( $self, $c, $val ) = @_; |
78 | eval { $c->visit('Model::Foo') }; |
79 | $c->res->body( $@ ? $@ : "visit() did not die" ); |
80 | } |
81 | |
82 | sub args_embed_relative : Local { |
83 | my ( $self, $c ) = @_; |
84 | $c->visit('embed/ok'); |
85 | } |
86 | |
87 | sub args_embed_absolute : Local { |
88 | my ( $self, $c ) = @_; |
89 | $c->visit('/action/visit/embed/ok'); |
90 | } |
91 | |
92 | sub embed : Local { |
93 | my ( $self, $c, $ok ) = @_; |
94 | $ok ||= 'not ok'; |
95 | $c->res->body($ok); |
96 | } |
97 | |
98 | sub class_visit_test_action : Local { |
99 | my ( $self, $c ) = @_; |
100 | $c->visit(qw/TestApp class_visit_test_method/); |
101 | } |
102 | |
103 | 1; |