Skip to content

Commit d589268

Browse files
committed
adding new tests to cover array and object rendering
1 parent 01a225f commit d589268

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/action_controller/serialization_test.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ def render_object_with_cache_enabled
4747
render json: @post
4848
end
4949

50+
def render_json_object_without_serializer
51+
render json: {error: 'Result is Invalid'}
52+
end
53+
54+
def render_json_array_object_without_serializer
55+
render json: [{error: 'Result is Invalid'}]
56+
end
57+
5058
def update_and_render_object_with_cache_enabled
5159
@post.updated_at = DateTime.now
5260

@@ -160,6 +168,20 @@ def test_render_using_default_root
160168
assert_equal expected.to_json, @response.body
161169
end
162170

171+
def test_render_json_object_without_serializer
172+
get :render_json_object_without_serializer
173+
174+
assert_equal 'application/json', @response.content_type
175+
assert_equal ({error: 'Result is Invalid'}).to_json, @response.body
176+
end
177+
178+
def test_render_json_array_object_without_serializer
179+
get :render_json_array_object_without_serializer
180+
181+
assert_equal 'application/json', @response.content_type
182+
assert_equal ([{error: 'Result is Invalid'}]).to_json, @response.body
183+
end
184+
163185
def test_render_array_using_implicit_serializer
164186
get :render_array_using_implicit_serializer
165187
assert_equal 'application/json', @response.content_type

0 commit comments

Comments
 (0)