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