Commit | Line | Data |
d91504e3 |
1 | use warnings; |
2 | use strict; |
3 | use Test::More; |
4 | use HTTP::Request::Common; |
5 | |
6 | { |
7 | package MyApp::Controller::Root; |
8 | $INC{'MyApp/Controller/Root.pm'} = __FILE__; |
9 | |
10 | use Moose; |
11 | use MooseX::MethodAttributes; |
12 | |
13 | extends 'Catalyst::Controller'; |
14 | |
6d62355b |
15 | sub an_int :Local Args(Int) { |
16 | my ($self, $c, $int) = @_; |
6d62355b |
17 | $c->res->body('an_int'); |
18 | } |
19 | |
4a0218ca |
20 | sub many_ints :Local Args(ArrayRef[Int]) { |
21 | my ($self, $c, $int) = @_; |
22 | $c->res->body('many_ints'); |
23 | } |
24 | |
e5604544 |
25 | sub any_priority :Path('priority_test') Args(1) { $_[1]->res->body('any_priority') } |
b7791bd7 |
26 | sub int_priority :Path('priority_test') Args(Int) { $_[1]->res->body('int_priority') } |
e5604544 |
27 | |
6d62355b |
28 | sub default :Default { |
29 | my ($self, $c, $int) = @_; |
30 | $c->res->body('default'); |
d91504e3 |
31 | } |
32 | |
33 | MyApp::Controller::Root->config(namespace=>''); |
34 | |
35 | package MyApp; |
36 | use Catalyst; |
37 | |
e5604544 |
38 | #MyApp->config(show_internal_actions => 1); |
d91504e3 |
39 | MyApp->setup; |
40 | } |
41 | |
42 | use Catalyst::Test 'MyApp'; |
43 | |
44 | { |
6d62355b |
45 | my $res = request '/an_int/1'; |
46 | is $res->content, 'an_int'; |
47 | } |
48 | |
49 | { |
337a627a |
50 | my $res = request '/an_int/aa'; |
51 | is $res->content, 'default'; |
52 | } |
53 | |
54 | { |
4a0218ca |
55 | my $res = request '/many_ints/1'; |
56 | is $res->content, 'many_ints'; |
57 | } |
58 | |
59 | { |
60 | my $res = request '/many_ints/1/2'; |
61 | is $res->content, 'many_ints'; |
62 | } |
63 | |
64 | { |
65 | my $res = request '/many_ints/1/2/3'; |
66 | is $res->content, 'many_ints'; |
67 | } |
68 | |
69 | { |
70 | my $res = request '/many_ints/1/2/a'; |
71 | is $res->content, 'default'; |
72 | } |
73 | |
e5604544 |
74 | { |
75 | my $res = request '/priority_test/1'; |
76 | is $res->content, 'int_priority'; |
77 | } |
78 | { |
79 | my $res = request '/priority_test/a'; |
80 | is $res->content, 'any_priority'; |
81 | } |
82 | |
d91504e3 |
83 | done_testing; |
81436df9 |
84 | |