mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Make 'map' filter work on Enumerable drops
This commit is contained in:
@@ -27,6 +27,14 @@ class TestDrop < Liquid::Drop
|
||||
end
|
||||
end
|
||||
|
||||
class TestEnumerable < Liquid::Drop
|
||||
include Enumerable
|
||||
|
||||
def each(&block)
|
||||
[ { "foo" => 1 }, { "foo" => 2 }, { "foo" => 3 } ].each(&block)
|
||||
end
|
||||
end
|
||||
|
||||
class StandardFiltersTest < Test::Unit::TestCase
|
||||
include Liquid
|
||||
|
||||
@@ -135,6 +143,10 @@ class StandardFiltersTest < Test::Unit::TestCase
|
||||
assert_equal "testfoo", Liquid::Template.parse(templ).render("procs" => [p])
|
||||
end
|
||||
|
||||
def test_map_works_on_enumerables
|
||||
assert_equal "123", Liquid::Template.parse('{{ foo | map: "foo" }}').render!("foo" => TestEnumerable.new)
|
||||
end
|
||||
|
||||
def test_date
|
||||
assert_equal 'May', @filters.date(Time.parse("2006-05-05 10:00:00"), "%B")
|
||||
assert_equal 'June', @filters.date(Time.parse("2006-06-05 10:00:00"), "%B")
|
||||
|
||||
Reference in New Issue
Block a user