Make all array filters that use filter_array util process empty string and nil correctly

This commit is contained in:
Marco Concetto Rudilosso
2025-04-02 11:01:51 +02:00
parent aa1640035f
commit 035a0db6ab
2 changed files with 22 additions and 1 deletions
+18
View File
@@ -1033,6 +1033,24 @@ 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: ' ' }}"
expected_output = "alpha beta gamma"
assert_template_result(expected_output, template, { "array" => array })
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)
end
def test_where_with_value
array = [
{ "handle" => "alpha", "ok" => true },