mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56: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
|
render json: @post
|
||||||
end
|
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
|
def update_and_render_object_with_cache_enabled
|
||||||
@post.updated_at = DateTime.now
|
@post.updated_at = DateTime.now
|
||||||
|
|
||||||
@ -160,6 +168,20 @@ module ActionController
|
|||||||
assert_equal expected.to_json, @response.body
|
assert_equal expected.to_json, @response.body
|
||||||
end
|
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
|
def test_render_array_using_implicit_serializer
|
||||||
get :render_array_using_implicit_serializer
|
get :render_array_using_implicit_serializer
|
||||||
assert_equal 'application/json', @response.content_type
|
assert_equal 'application/json', @response.content_type
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user