mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 15:23:06 +00:00
Fix serializer.as_json(nil)
This is the form that ActiveSupport 3.1 Object#to_json invokes.
This commit is contained in:
@@ -1449,4 +1449,17 @@ class SerializerTest < ActiveModel::TestCase
|
||||
}
|
||||
}, post_serializer.as_json)
|
||||
end
|
||||
|
||||
def test_as_json_with_nil_options
|
||||
user = User.new
|
||||
user_serializer = DefaultUserSerializer.new(user, {})
|
||||
|
||||
# ActiveSupport 3.1 Object#to_json generates this downstream call
|
||||
assert_equal({
|
||||
:default_user => {
|
||||
:first_name => "Jose",
|
||||
:last_name => "Valim"
|
||||
}
|
||||
}, user_serializer.as_json(nil))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user