mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Add test and bugfix to include an array of string
This commit is contained in:
parent
0200d89da8
commit
6407dbeadd
@ -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