Use REST::ForBrowsers action class
[catagits/CatalystX-Routes.git] / t / routes.t
index 9f63dd2..15d0368 100644 (file)
@@ -7,58 +7,109 @@ use lib 't/lib';
 use Catalyst::Test 'MyApp1';
 use HTTP::Request::Common qw( GET PUT POST DELETE );
 
-get('/foo');
-
-is(
-    $MyApp1::Controller::C1::REQ{get}, 1,
-    'GET request for /foo went to the right sub'
-);
-
-request(
-    GET '/foo',
-    [
-        Accept => '*/*',
-    ]
-);
-
-is(
-    $MyApp1::Controller::C1::REQ{get_html}, 1,
-    'GET request for /foo that looks like a browser went to the right sub'
-);
-
-request( POST '/foo' );
-
-is(
-    $MyApp1::Controller::C1::REQ{post}, 1,
-    'POST request for /foo went to the right sub'
-);
-
-request( PUT '/foo' );
-
-is(
-    $MyApp1::Controller::C1::REQ{put}, 1,
-    'PUT request for /foo went to the right sub'
-);
-
-request( DELETE '/foo' );
-
-is(
-    $MyApp1::Controller::C1::REQ{delete}, 1,
-    'DELETE request for /foo went to the right sub'
-);
-
-get('/normal');
-
-is(
-    $MyApp1::Controller::C1::REQ{normal}, 1,
-    'GET request for /norma went to the right sub'
-);
-
-request( POST '/normal' );
-
-is(
-    $MyApp1::Controller::C1::REQ{normal}, 2,
-    'POST request for /norma went to the right sub'
-);
+{
+    request(
+        GET '/foo',
+        [
+            Accept => 'application/json',
+        ]
+    );
+
+    is(
+        $MyApp1::Controller::C1::REQ{get}, 1,
+        'GET request for /foo went to the right sub'
+    );
+
+    request(
+        GET '/foo',
+        [
+            Accept => '*/*',
+        ]
+    );
+
+    is(
+        $MyApp1::Controller::C1::REQ{get_html}, 1,
+        'GET request for /foo that looks like a browser went to the right sub'
+    );
+
+    request( POST '/foo' );
+
+    is(
+        $MyApp1::Controller::C1::REQ{post}, 1,
+        'POST request for /foo went to the right sub'
+    );
+
+    request( PUT '/foo' );
+
+    is(
+        $MyApp1::Controller::C1::REQ{put}, 1,
+        'PUT request for /foo went to the right sub'
+    );
+
+    request( DELETE '/foo' );
+
+    is(
+        $MyApp1::Controller::C1::REQ{delete}, 1,
+        'DELETE request for /foo went to the right sub'
+    );
+}
+
+{
+    get('c1/bar');
+
+    is(
+        $MyApp1::Controller::C1::REQ{get}, 2,
+        'GET request for c1/bar went to the right sub'
+    );
+
+    request(
+        GET 'c1/bar',
+        [
+            Accept => '*/*',
+        ]
+    );
+
+    is(
+        $MyApp1::Controller::C1::REQ{get_html}, 2,
+        'GET request for c1/bar that looks like a browser went to the right sub'
+    );
+
+    request( POST 'c1/bar' );
+
+    is(
+        $MyApp1::Controller::C1::REQ{post}, 2,
+        'POST request for c1/bar went to the right sub'
+    );
+
+    request( PUT 'c1/bar' );
+
+    is(
+        $MyApp1::Controller::C1::REQ{put}, 2,
+        'PUT request for c1/bar went to the right sub'
+    );
+
+    request( DELETE 'c1/bar' );
+
+    is(
+        $MyApp1::Controller::C1::REQ{delete}, 2,
+        'DELETE request for c1/bar went to the right sub'
+    );
+}
+
+{
+    get('/normal');
+
+    is(
+        $MyApp1::Controller::C1::REQ{normal}, 1,
+        'GET request for /norma went to the right sub'
+    );
+
+    request( POST '/normal' );
+
+    is(
+        $MyApp1::Controller::C1::REQ{normal}, 2,
+        'POST request for /norma went to the right sub'
+    );
+}
 
 done_testing();