Commit | Line | Data |
518b6198 |
1 | use Test::Most; |
2 | |
3 | { |
4 | package MyApp::Controller::Root; |
5 | $INC{'MyApp/Controller/Root.pm'} = __FILE__; |
6 | |
7 | use Moose; |
8 | use MooseX::MethodAttributes; |
9 | |
10 | extends 'Catalyst::Controller'; |
11 | |
12 | sub root :Chained(/) PathPart('') CaptureArgs(0) { |
13 | my ($self, $c) = @_; |
14 | } |
15 | |
16 | sub top :Chained('root') Args(0) { |
17 | my ($self, $c) = @_; |
18 | Test::Most::is $self->action_for('top'), 'top'; |
19 | Test::Most::is $self->action_for('story/story'), 'story/story'; |
518b6198 |
20 | } |
21 | |
22 | MyApp::Controller::Root->config(namespace=>''); |
23 | |
24 | package MyApp::Controller::Story; |
25 | $INC{'MyApp/Controller/Story.pm'} = __FILE__; |
26 | |
27 | use Moose; |
28 | use MooseX::MethodAttributes; |
29 | |
30 | extends 'Catalyst::Controller'; |
31 | |
32 | sub root :Chained(/root) PathPart('') CaptureArgs(0) { |
33 | my ($self, $c) = @_; |
34 | } |
35 | |
36 | sub story :Chained(root) Args(0) { |
37 | my ($self, $c) = @_; |
38 | |
39 | Test::Most::is $self->action_for('story'), 'story/story'; |
40 | Test::Most::is $self->action_for('author/author'), 'story/author/author'; |
41 | } |
42 | |
43 | __PACKAGE__->meta->make_immutable; |
44 | |
45 | package MyApp::Controller::Story::Author; |
46 | $INC{'MyApp/Controller/Story/Author.pm'} = __FILE__; |
47 | |
48 | use Moose; |
49 | use MooseX::MethodAttributes; |
50 | |
51 | extends 'Catalyst::Controller'; |
52 | |
53 | sub root :Chained(/story/root) PathPart('') CaptureArgs(0) { |
54 | my ($self, $c) = @_; |
55 | } |
56 | |
57 | sub author :Chained(root) Args(0) { |
58 | my ($self, $c, $id) = @_; |
59 | Test::Most::is $self->action_for('author'), 'story/author/author'; |
6e3dd95f |
60 | Test::Most::is $self->action_for('../story'), 'story/story'; |
61 | Test::Most::is $self->action_for('../../top'), 'top'; |
518b6198 |
62 | } |
63 | |
518b6198 |
64 | __PACKAGE__->meta->make_immutable; |
65 | |
66 | package MyApp; |
67 | $INC{'MyApp.pm'} = __FILE__; |
68 | |
69 | use Catalyst; |
70 | |
71 | MyApp->setup; |
72 | } |
73 | |
74 | use Catalyst::Test 'MyApp'; |
75 | |
6e3dd95f |
76 | ok request '/top'; |
518b6198 |
77 | ok request '/story'; |
78 | ok request '/author'; |
518b6198 |
79 | |
6e3dd95f |
80 | done_testing(10); |
518b6198 |
81 | |