File: relative_root_action_for_bug.t

package info (click to toggle)
libcatalyst-perl 5.90132-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,016 kB
  • sloc: perl: 11,061; makefile: 7
file content (93 lines) | stat: -rw-r--r-- 2,080 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
use warnings;
use strict;
use Test::More;

{
    package MyApp::Controller::Root;
    $INC{'MyApp/Controller/Root.pm'} = __FILE__;

    use Moose;
    use MooseX::MethodAttributes;

    extends 'Catalyst::Controller';

    sub root :Chained(/) PathPart('') CaptureArgs(0) {
      my ($self, $c) = @_;
    }

    sub top :Chained('root') Args(0) {
      my ($self, $c) = @_;
      Test::More::is $self->action_for('top'), 'top';
      Test::More::is $self->action_for('story/story'), 'story/story';
    }

    sub default : Path {

        my ($self, $c) = @_;
        $c->response->body("Ok");
    }

    MyApp::Controller::Root->config(namespace=>'');

    package MyApp::Controller::Story;
    $INC{'MyApp/Controller/Story.pm'} = __FILE__;

    use Moose;
    use MooseX::MethodAttributes;

    extends 'Catalyst::Controller';

    sub root :Chained(/root) PathPart('') CaptureArgs(0) {
      my ($self, $c) = @_;
    }

    sub story :Chained(root) Args(0) {
      my ($self, $c) = @_;

      Test::More::is $self->action_for('story'), 'story/story';
      Test::More::is $self->action_for('author/author'), 'story/author/author';
    }

    __PACKAGE__->meta->make_immutable;

    package MyApp::Controller::Story::Author;
    $INC{'MyApp/Controller/Story/Author.pm'} = __FILE__;

    use Moose;
    use MooseX::MethodAttributes;

    extends 'Catalyst::Controller';

    sub root :Chained(/story/root) PathPart('') CaptureArgs(0) {
      my ($self, $c) = @_;
    }

    sub author :Chained(root) Args(0) {
      my ($self, $c, $id) = @_;
      Test::More::is $self->action_for('author'), 'story/author/author';
      Test::More::is $self->action_for('../story'), 'story/story';
      Test::More::is $self->action_for('../../top'), 'top';
    }

    __PACKAGE__->meta->make_immutable;

    package MyApp;
    $INC{'MyApp.pm'} = __FILE__;

    use Catalyst;

    MyApp->setup;
}

use Catalyst::Test 'MyApp';

ok request '/top';
ok request '/story';
ok request '/author';
ok request '/double';
ok request '/double/file.ext';
ok request '/double/file..ext';


done_testing(13);