Add a json_options key to the REST controller
[catagits/Catalyst-Action-REST.git] / t / json.t
index 673c0a9..35d6059 100644 (file)
--- a/t/json.t
+++ b/t/json.t
@@ -10,7 +10,7 @@ use utf8;
 eval 'use JSON 2.12';
 plan skip_all => 'Install JSON 2.12 or later to run this test' if ($@);
 
-plan tests => 9;
+plan tests => 11;
 
 use_ok 'Catalyst::Test', 'Test::Serialize';
 
@@ -36,4 +36,14 @@ for ('text/x-json', 'application/json') {
     is_deeply($mres_post->content, $exp, "POST data matches");
 }
 
+{
+    my $t = Test::Rest->new('content_type' => 'application/json');
+    my $json_data = '{ "sushi":"is good for monkey", }';
+    my $mres_post = request($t->post(url => '/monkey_put', data => $json_data));
+    ok( ! $mres_post->is_success, "Got expected failed status due to invalid JSON" );
+
+    my $relaxed_post = request( $t->post(url => "/monkey_json_put", data => $json_data));
+    ok( $relaxed_post->is_success, "Got success due to setting relaxed JSON input" );
+}
+
 1;