From 7900043ffc2331bb7d1d17a87e79c9d2d019c04f Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 2 Apr 2025 22:18:09 -0400 Subject: [PATCH] Do not raise property error --- lib/liquid/standardfilters.rb | 6 +----- test/integration/standard_filter_test.rb | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/lib/liquid/standardfilters.rb b/lib/liquid/standardfilters.rb index f20514fb..c7a841cc 100644 --- a/lib/liquid/standardfilters.rb +++ b/lib/liquid/standardfilters.rb @@ -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? diff --git a/test/integration/standard_filter_test.rb b/test/integration/standard_filter_test.rb index 13369541..86cdadaa 100644 --- a/test/integration/standard_filter_test.rb +++ b/test/integration/standard_filter_test.rb @@ -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