mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Throw a descriptive error if attempting to serialize an array with Serializer not ArraySerializer #143
This commit is contained in:
@@ -152,6 +152,10 @@ class RenderJsonTest < ActionController::TestCase
|
||||
render :json => [Object.new], :each_serializer => CustomSerializer
|
||||
end
|
||||
|
||||
def render_json_array_with_wrong_option
|
||||
render :json => [Object.new], :serializer => CustomSerializer
|
||||
end
|
||||
|
||||
def render_json_with_links
|
||||
render :json => HypermediaSerializable.new
|
||||
end
|
||||
@@ -286,6 +290,12 @@ class RenderJsonTest < ActionController::TestCase
|
||||
assert_match '{"test":[{"hello":true}]}', @response.body
|
||||
end
|
||||
|
||||
def test_render_json_array_with_wrong_option
|
||||
assert_raise ArgumentError do
|
||||
get :render_json_array_with_wrong_option
|
||||
end
|
||||
end
|
||||
|
||||
def test_render_json_with_links
|
||||
get :render_json_with_links
|
||||
assert_match '{"link":"http://www.nextangle.com/hypermedia"}', @response.body
|
||||
|
||||
Reference in New Issue
Block a user