add tests which prove the current behavior of not decoding chained args but decoding...
[catagits/Catalyst-Runtime.git] / t / aggregate / live_component_controller_action_local.t
CommitLineData
50cc3183 1#!perl
2
3use strict;
4use warnings;
5
6use FindBin;
42da66a9 7use lib "$FindBin::Bin/../lib";
50cc3183 8
9our $iters;
10
6b25e555 11BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
50cc3183 12
2c527b91 13use Test::More tests => 34*$iters;
50cc3183 14use Catalyst::Test 'TestApp';
15
16if ( $ENV{CAT_BENCHMARK} ) {
17 require Benchmark;
18 Benchmark::timethis( $iters, \&run_tests );
19}
20else {
21 for ( 1 .. $iters ) {
22 run_tests();
23 }
24}
25
26sub run_tests {
27 {
28 ok( my $response = request('http://localhost/action/local/one'),
29 'Request' );
30 ok( $response->is_success, 'Response Successful 2xx' );
31 is( $response->content_type, 'text/plain', 'Response Content-Type' );
32 is( $response->header('X-Catalyst-Action'),
33 'action/local/one', 'Test Action' );
34 is(
35 $response->header('X-Test-Class'),
36 'TestApp::Controller::Action::Local',
37 'Test Class'
38 );
39 like(
40 $response->content,
41 qr/^bless\( .* 'Catalyst::Request' \)$/s,
42 'Content is a serialized Catalyst::Request'
43 );
44 }
45
46 {
4082e678 47 ok( my $response = request('http://localhost/action/local/two/1/2'),
50cc3183 48 'Request' );
49 ok( $response->is_success, 'Response Successful 2xx' );
50 is( $response->content_type, 'text/plain', 'Response Content-Type' );
51 is( $response->header('X-Catalyst-Action'),
52 'action/local/two', 'Test Action' );
53 is(
54 $response->header('X-Test-Class'),
55 'TestApp::Controller::Action::Local',
56 'Test Class'
57 );
58 like(
59 $response->content,
60 qr/^bless\( .* 'Catalyst::Request' \)$/s,
61 'Content is a serialized Catalyst::Request'
62 );
63 }
64
65 {
4082e678 66 ok( my $response = request('http://localhost/action/local/two'),
67 'Request' );
68 ok( !$response->is_success, 'Request with wrong number of args failed' );
69 }
70
71 {
50cc3183 72 ok( my $response = request('http://localhost/action/local/three'),
73 'Request' );
74 ok( $response->is_success, 'Response Successful 2xx' );
75 is( $response->content_type, 'text/plain', 'Response Content-Type' );
76 is( $response->header('X-Catalyst-Action'),
77 'action/local/three', 'Test Action' );
78 is(
79 $response->header('X-Test-Class'),
80 'TestApp::Controller::Action::Local',
81 'Test Class'
82 );
83 like(
84 $response->content,
85 qr/^bless\( .* 'Catalyst::Request' \)$/s,
86 'Content is a serialized Catalyst::Request'
87 );
88 }
89
90 {
91 ok(
92 my $response =
93 request('http://localhost/action/local/four/five/six'),
94 'Request'
95 );
96 ok( $response->is_success, 'Response Successful 2xx' );
97 is( $response->content_type, 'text/plain', 'Response Content-Type' );
98 is( $response->header('X-Catalyst-Action'),
99 'action/local/four/five/six', 'Test Action' );
100 is(
101 $response->header('X-Test-Class'),
102 'TestApp::Controller::Action::Local',
103 'Test Class'
104 );
105 like(
106 $response->content,
107 qr/^bless\( .* 'Catalyst::Request' \)$/s,
108 'Content is a serialized Catalyst::Request'
109 );
110 }
595f3872 111
5884ba38 112 SKIP:
113 {
114 if ( $ENV{CATALYST_SERVER} ) {
115 skip "tests for %2F on remote server", 6;
116 }
117
595f3872 118 ok(
119 my $response =
4082e678 120 request('http://localhost/action/local/one/foo%2Fbar'),
595f3872 121 'Request'
122 );
123 ok( $response->is_success, 'Response Successful 2xx' );
124 is( $response->content_type, 'text/plain', 'Response Content-Type' );
125 is( $response->header('X-Catalyst-Action'),
4082e678 126 'action/local/one', 'Test Action' );
595f3872 127 is(
128 $response->header('X-Test-Class'),
129 'TestApp::Controller::Action::Local',
130 'Test Class'
131 );
132 like(
133 $response->content,
855ed931 134 qr~arguments => \[\s*'foo/bar'\s*\]~,
595f3872 135 "Parameters don't split on %2F"
136 );
137 }
2c527b91 138
139 {
140 ok( my $content = get('http://locahost/action/local/five/foo%2Fbar%3B'),
141 'request with URI-encoded arg');
142 # this is the CURRENT behavior
143 like( $content, qr{'foo/bar;'}, 'args for Local actions URI-decoded' );
144 }
50cc3183 145}