Ensure we use InputIterator#each when in join filter (#1898)

This commit is contained in:
Ian Ker-Seymer
2025-01-16 11:36:36 -05:00
committed by GitHub
parent 0ec52a40b5
commit 6372289ba3
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -1065,7 +1065,7 @@ module Liquid
def join(glue)
first = true
output = +""
@input.each do |item|
each do |item|
if first
first = false
else
+10
View File
@@ -305,6 +305,16 @@ class StandardFiltersTest < Minitest::Test
assert_equal('1121314', @filters.join([1, 2, 3, 4], 1))
end
def test_join_calls_to_liquid_on_each_element
drop = Class.new(Liquid::Drop) do
def to_liquid
'i did it'
end
end
assert_equal('i did it, i did it', @filters.join([drop.new, drop.new], ", "))
end
def test_sort
assert_equal([1, 2, 3, 4], @filters.sort([4, 3, 2, 1]))
assert_equal([{ "a" => 1 }, { "a" => 2 }, { "a" => 3 }, { "a" => 4 }], @filters.sort([{ "a" => 4 }, { "a" => 3 }, { "a" => 1 }, { "a" => 2 }], "a"))