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 | |
0fd0114d |
22 | sub default : Path { |
23 | |
24 | my ($self, $c) = @_; |
25 | $c->response->body("Ok"); |
26 | } |
27 | |
518b6198 |
28 | MyApp::Controller::Root->config(namespace=>''); |
29 | |
30 | package MyApp::Controller::Story; |
31 | $INC{'MyApp/Controller/Story.pm'} = __FILE__; |
32 | |
33 | use Moose; |
34 | use MooseX::MethodAttributes; |
35 | |
36 | extends 'Catalyst::Controller'; |
37 | |
38 | sub root :Chained(/root) PathPart('') CaptureArgs(0) { |
39 | my ($self, $c) = @_; |
40 | } |
41 | |
42 | sub story :Chained(root) Args(0) { |
43 | my ($self, $c) = @_; |
44 | |
45 | Test::Most::is $self->action_for('story'), 'story/story'; |
46 | Test::Most::is $self->action_for('author/author'), 'story/author/author'; |
47 | } |
48 | |
49 | __PACKAGE__->meta->make_immutable; |
50 | |
51 | package MyApp::Controller::Story::Author; |
52 | $INC{'MyApp/Controller/Story/Author.pm'} = __FILE__; |
53 | |
54 | use Moose; |
55 | use MooseX::MethodAttributes; |
56 | |
57 | extends 'Catalyst::Controller'; |
58 | |
59 | sub root :Chained(/story/root) PathPart('') CaptureArgs(0) { |
60 | my ($self, $c) = @_; |
61 | } |
62 | |
63 | sub author :Chained(root) Args(0) { |
64 | my ($self, $c, $id) = @_; |
65 | Test::Most::is $self->action_for('author'), 'story/author/author'; |
6e3dd95f |
66 | Test::Most::is $self->action_for('../story'), 'story/story'; |
67 | Test::Most::is $self->action_for('../../top'), 'top'; |
518b6198 |
68 | } |
69 | |
518b6198 |
70 | __PACKAGE__->meta->make_immutable; |
71 | |
72 | package MyApp; |
73 | $INC{'MyApp.pm'} = __FILE__; |
74 | |
75 | use Catalyst; |
76 | |
77 | MyApp->setup; |
78 | } |
79 | |
80 | use Catalyst::Test 'MyApp'; |
81 | |
6e3dd95f |
82 | ok request '/top'; |
518b6198 |
83 | ok request '/story'; |
84 | ok request '/author'; |
0fd0114d |
85 | ok request '/double'; |
86 | ok request '/double/file.ext'; |
87 | ok request '/double/file..ext'; |
88 | |
518b6198 |
89 | |
0fd0114d |
90 | done_testing(13); |
518b6198 |
91 | |