mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Merge pull request #1320 from barodeur/include-array-of-string
Add test and bugfix to include an array of string
This commit is contained in:
commit
e6d1d6be0c
@ -52,7 +52,7 @@ module ActiveModel
|
|||||||
hash[key] = include_args_to_hash(value)
|
hash[key] = include_args_to_hash(value)
|
||||||
end
|
end
|
||||||
when Array
|
when Array
|
||||||
included.reduce({}) { |a, e| a.merge!(include_args_to_hash(e)) }
|
included.reduce({}) { |a, e| a.deep_merge!(include_args_to_hash(e)) }
|
||||||
when String
|
when String
|
||||||
include_string_to_hash(included)
|
include_string_to_hash(included)
|
||||||
else
|
else
|
||||||
|
|||||||
@ -44,6 +44,19 @@ module ActiveModel
|
|||||||
|
|
||||||
assert_equal(expected, actual)
|
assert_equal(expected, actual)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_array_of_string
|
||||||
|
expected = {
|
||||||
|
comments: { author: {}, attachment: {} }
|
||||||
|
}
|
||||||
|
input = [
|
||||||
|
'comments.author',
|
||||||
|
'comments.attachment'
|
||||||
|
]
|
||||||
|
actual = Parsing.include_args_to_hash(input)
|
||||||
|
|
||||||
|
assert_equal(expected, actual)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user