-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
109 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
test/unit/active_model/array_serializer/key_format_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'test_helper' | ||
|
||
module ActiveModel | ||
class ArraySerializer | ||
class KeyFormatTest < Minitest::Test | ||
def test_array_serializer_pass_options_to_items_serializers | ||
array = [Blog.new({ name: 'Name 1', display_name: 'Display Name 1'}), | ||
Blog.new({ name: 'Name 2', display_name: 'Display Name 2'})] | ||
serializer = ArraySerializer.new(array, key_format: :lower_camel) | ||
|
||
expected = [{ name: 'Name 1', displayName: 'Display Name 1' }, | ||
{ name: 'Name 2', displayName: 'Display Name 2' }] | ||
|
||
assert_equal expected, serializer.serializable_array | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |