mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
adding new tests to cover array and object rendering
This commit is contained in:
parent
01a225f0e4
commit
d589268f95
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user