whitespace cleanup
[catagits/Catalyst-Runtime.git] / t / relative_root_action_for_bug.t
CommitLineData
7213dd01 1use warnings;
2use strict;
3use Test::More;
518b6198 4
5{
6 package MyApp::Controller::Root;
7 $INC{'MyApp/Controller/Root.pm'} = __FILE__;
8
9 use Moose;
10 use MooseX::MethodAttributes;
11
12 extends 'Catalyst::Controller';
13
14 sub root :Chained(/) PathPart('') CaptureArgs(0) {
15 my ($self, $c) = @_;
16 }
17
18 sub top :Chained('root') Args(0) {
19 my ($self, $c) = @_;
7213dd01 20 Test::More::is $self->action_for('top'), 'top';
21 Test::More::is $self->action_for('story/story'), 'story/story';
518b6198 22 }
23
0fd0114d 24 sub default : Path {
25
26 my ($self, $c) = @_;
27 $c->response->body("Ok");
28 }
29
518b6198 30 MyApp::Controller::Root->config(namespace=>'');
31
32 package MyApp::Controller::Story;
33 $INC{'MyApp/Controller/Story.pm'} = __FILE__;
34
35 use Moose;
36 use MooseX::MethodAttributes;
37
38 extends 'Catalyst::Controller';
39
40 sub root :Chained(/root) PathPart('') CaptureArgs(0) {
41 my ($self, $c) = @_;
42 }
43
44 sub story :Chained(root) Args(0) {
45 my ($self, $c) = @_;
46
7213dd01 47 Test::More::is $self->action_for('story'), 'story/story';
48 Test::More::is $self->action_for('author/author'), 'story/author/author';
518b6198 49 }
50
51 __PACKAGE__->meta->make_immutable;
52
53 package MyApp::Controller::Story::Author;
54 $INC{'MyApp/Controller/Story/Author.pm'} = __FILE__;
55
56 use Moose;
57 use MooseX::MethodAttributes;
58
59 extends 'Catalyst::Controller';
60
61 sub root :Chained(/story/root) PathPart('') CaptureArgs(0) {
62 my ($self, $c) = @_;
63 }
64
65 sub author :Chained(root) Args(0) {
66 my ($self, $c, $id) = @_;
7213dd01 67 Test::More::is $self->action_for('author'), 'story/author/author';
68 Test::More::is $self->action_for('../story'), 'story/story';
69 Test::More::is $self->action_for('../../top'), 'top';
518b6198 70 }
71
518b6198 72 __PACKAGE__->meta->make_immutable;
73
74 package MyApp;
75 $INC{'MyApp.pm'} = __FILE__;
76
77 use Catalyst;
78
79 MyApp->setup;
80}
81
82use Catalyst::Test 'MyApp';
83
6e3dd95f 84ok request '/top';
518b6198 85ok request '/story';
86ok request '/author';
0fd0114d 87ok request '/double';
88ok request '/double/file.ext';
89ok request '/double/file..ext';
90
518b6198 91
0fd0114d 92done_testing(13);
518b6198 93