Commit | Line | Data |
75f37967 |
1 | # Copyright (c) 2007 Jonathan Rockway <jrockway@cpan.org> |
2 | |
6166f03d |
3 | package TestApp::Controller::Root; |
4 | use strict; |
5 | use warnings; |
75f37967 |
6 | use base qw/Catalyst::Component::ACCEPT_CONTEXT Catalyst::Controller/; |
7 | use Devel::Cycle; |
8 | |
9 | __PACKAGE__->config(namespace => ''); |
10 | |
11 | sub model : Global { |
12 | my ($self, $c) = @_; |
13 | $c->stash->{message} = "model"; |
14 | $c->res->body($c->model('Test')->message); |
15 | } |
16 | |
17 | sub view : Global { |
18 | my ($self, $c) = @_; |
19 | $c->stash->{message} = "view"; |
20 | $c->res->body($c->view('Test')->message); |
21 | } |
6166f03d |
22 | |
75f37967 |
23 | sub controller : Global { |
24 | my ($self, $c) = @_; |
25 | $c->res->body("controller"); |
26 | } |
6166f03d |
27 | |
75f37967 |
28 | sub foo : Global { |
29 | my ($self, $c) = @_; |
30 | $c->res->body($c->model('Test')->foo); |
31 | } |
6166f03d |
32 | |
75f37967 |
33 | sub stash : Global { |
34 | my ($self, $c) = @_; |
35 | $c->model('StashMe')->test; |
36 | $c->res->body($c->stash->{stashme}->foo); |
37 | } |
38 | |
39 | sub cycle : Global { |
40 | my ($self, $c) = @_; |
41 | $c->model('StashMe')->test; |
42 | my $cycle_ok = 1; |
43 | my $got_cycle = sub { $cycle_ok = 0 }; |
44 | find_cycle($c, $got_cycle); |
45 | $c->res->body($cycle_ok); |
46 | } |
47 | |
48 | sub weak_cycle :Global { |
49 | my ($self, $c) = @_; |
50 | $c->model('StashMe')->test; |
51 | my $cycle_ok = 0; |
52 | my $got_cycle = sub { $cycle_ok = 1 }; |
53 | find_weakened_cycle($c, $got_cycle); |
54 | $c->res->body($cycle_ok); |
55 | } |
6166f03d |
56 | |
57 | 1; |
75f37967 |
58 | |