mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 11:20:41 -07:00
Do not raise property error
This commit is contained in:
@@ -992,11 +992,7 @@ module Liquid
|
|||||||
ary = InputIterator.new(input, context)
|
ary = InputIterator.new(input, context)
|
||||||
return default_value if ary.empty?
|
return default_value if ary.empty?
|
||||||
|
|
||||||
if property.nil?
|
property = Utils.to_s(property)
|
||||||
raise_property_error(property)
|
|
||||||
end
|
|
||||||
|
|
||||||
property = Liquid::Utils.to_s(property)
|
|
||||||
|
|
||||||
block.call(ary) do |item|
|
block.call(ary) do |item|
|
||||||
if target_value.nil?
|
if target_value.nil?
|
||||||
|
|||||||
@@ -1033,22 +1033,20 @@ class StandardFiltersTest < Minitest::Test
|
|||||||
assert_template_result(expected_output, template, { "array" => array })
|
assert_template_result(expected_output, template, { "array" => array })
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_where_with_empty_string_and_nil
|
def test_where_with_empty_string_is_a_no_op
|
||||||
array = [
|
environment = { "array" => ["alpha", "beta", "gamma"] }
|
||||||
"alpha",
|
|
||||||
"beta",
|
|
||||||
"gamma",
|
|
||||||
]
|
|
||||||
template = "{{ array | where: '' | join: ' ' }}"
|
|
||||||
expected_output = "alpha beta gamma"
|
expected_output = "alpha beta gamma"
|
||||||
assert_template_result(expected_output, template, { "array" => array })
|
template = "{{ array | where: '' | join: ' ' }}"
|
||||||
|
|
||||||
|
assert_template_result(expected_output, template, environment)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_where_with_nil_is_a_no_op
|
||||||
|
environment = { "array" => ["alpha", "beta", "gamma"] }
|
||||||
|
expected_output = "alpha beta gamma"
|
||||||
template = "{{ array | where: nil | join: ' ' }}"
|
template = "{{ array | where: nil | join: ' ' }}"
|
||||||
exception = assert_raises(Liquid::ArgumentError) do
|
|
||||||
assert_template_result(expected_output, template, { "array" => array })
|
|
||||||
end
|
|
||||||
|
|
||||||
assert_equal("Liquid error (line 1): cannot select the property ''", exception.message)
|
assert_template_result(expected_output, template, environment)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_where_with_value
|
def test_where_with_value
|
||||||
|
|||||||
Reference in New Issue
Block a user