mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 09:05:13 -07:00
Raise a Liquid::Error when a non-array is passed into the concat filter.
This commit is contained in:
@@ -216,6 +216,9 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def concat(input, array)
|
def concat(input, array)
|
||||||
|
unless array.respond_to?(:to_ary)
|
||||||
|
raise ArgumentError.new("concat filter requires an array argument")
|
||||||
|
end
|
||||||
InputIterator.new(input).concat(array)
|
InputIterator.new(input).concat(array)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -370,7 +373,7 @@ module Liquid
|
|||||||
end
|
end
|
||||||
|
|
||||||
def concat(args)
|
def concat(args)
|
||||||
to_a.concat args
|
to_a.concat(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def reverse
|
def reverse
|
||||||
|
|||||||
@@ -463,8 +463,7 @@ class StandardFiltersTest < Minitest::Test
|
|||||||
assert_equal [1, 2, 'a'], @filters.concat([1, 2], ['a'])
|
assert_equal [1, 2, 'a'], @filters.concat([1, 2], ['a'])
|
||||||
assert_equal [1, 2, 10], @filters.concat([1, 2], [10])
|
assert_equal [1, 2, 10], @filters.concat([1, 2], [10])
|
||||||
|
|
||||||
assert_raises(TypeError) do
|
assert_raises(Liquid::ArgumentError, "concat filter requires an array argument") do
|
||||||
# no implicit conversion of Fixnum into Array
|
|
||||||
@filters.concat([1, 2], 10)
|
@filters.concat([1, 2], 10)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user