Skip to content

Commit

Permalink
Ensure we use InputIterator#each when in join filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ianks committed Jan 16, 2025
1 parent 0ec52a4 commit df53bc2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/liquid/standardfilters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ def initialize(input, context)
def join(glue)
first = true
output = +""
@input.each do |item|
each do |item|
if first
first = false
else
Expand Down
10 changes: 10 additions & 0 deletions test/integration/standard_filter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,16 @@ def test_join
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"))
Expand Down

0 comments on commit df53bc2

Please sign in to comment.