Add test and bugfix to include an array of string

This commit is contained in:
Paul Chobert 2015-11-06 17:23:25 +01:00
parent 0200d89da8
commit 6407dbeadd
2 changed files with 14 additions and 1 deletions

View File

@ -52,7 +52,7 @@ module ActiveModel
hash[key] = include_args_to_hash(value)
end
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
include_string_to_hash(included)
else

View File

@ -44,6 +44,19 @@ module ActiveModel
assert_equal(expected, actual)
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