From d589268f952f9840c4b0253eb2c5f2acd56b6ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moura?= Date: Mon, 22 Jun 2015 03:15:05 -0300 Subject: [PATCH] adding new tests to cover array and object rendering --- test/action_controller/serialization_test.rb | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/action_controller/serialization_test.rb b/test/action_controller/serialization_test.rb index 08b32035..a8c8f827 100644 --- a/test/action_controller/serialization_test.rb +++ b/test/action_controller/serialization_test.rb @@ -47,6 +47,14 @@ module ActionController render json: @post end + def render_json_object_without_serializer + render json: {error: 'Result is Invalid'} + end + + def render_json_array_object_without_serializer + render json: [{error: 'Result is Invalid'}] + end + def update_and_render_object_with_cache_enabled @post.updated_at = DateTime.now @@ -160,6 +168,20 @@ module ActionController assert_equal expected.to_json, @response.body end + def test_render_json_object_without_serializer + get :render_json_object_without_serializer + + assert_equal 'application/json', @response.content_type + assert_equal ({error: 'Result is Invalid'}).to_json, @response.body + end + + def test_render_json_array_object_without_serializer + get :render_json_array_object_without_serializer + + assert_equal 'application/json', @response.content_type + assert_equal ([{error: 'Result is Invalid'}]).to_json, @response.body + end + def test_render_array_using_implicit_serializer get :render_array_using_implicit_serializer assert_equal 'application/json', @response.content_type