Support lowerCamel key format

This commit is contained in:
Kyle Fritz
2014-03-30 11:53:24 -04:00
parent 2e31a14125
commit 00c54baae3
8 changed files with 109 additions and 3 deletions

View File

@@ -67,6 +67,7 @@ module ActiveModel
def test_apply_config_to_associations
CONFIG.embed = :ids
CONFIG.embed_in_root = true
CONFIG.key_format = :lower_camel
association = PostSerializer._associations[:comments]
old_association = association.dup
@@ -76,6 +77,7 @@ module ActiveModel
assert association.embed_ids?
assert !association.embed_objects?
assert association.embed_in_root
assert_equal :lower_camel, association.key_format
ensure
PostSerializer._associations[:comments] = old_association
CONFIG.clear

View File

@@ -0,0 +1,25 @@
require 'test_helper'
module ActiveModel
class Serializer
class KeyFormatTest < Minitest::Test
def test_lower_camel_format_option
object = Blog.new({ name: 'Name 1', display_name: 'Display Name 1'})
serializer = BlogSerializer.new(object, key_format: :lower_camel)
expected = { name: 'Name 1', displayName: 'Display Name 1' }
assert_equal expected, serializer.serializable_object
end
def test_lower_camel_format_serializer
object = Blog.new({ name: 'Name 1', display_name: 'Display Name 1'})
serializer = BlogLowerCamelSerializer.new(object)
expected = { name: 'Name 1', displayName: 'Display Name 1' }
assert_equal expected, serializer.serializable_object
end
end
end
end