Make sort filter work on Enumerable drops

This commit is contained in:
Florian Weingarten
2013-08-08 11:47:26 -04:00
parent 98c184f2fb
commit 8f978ecd1a
2 changed files with 17 additions and 11 deletions
+5 -1
View File
@@ -31,7 +31,7 @@ class TestEnumerable < Liquid::Drop
include Enumerable
def each(&block)
[ { "foo" => 1 }, { "foo" => 2 }, { "foo" => 3 } ].each(&block)
[ { "foo" => 1, "bar" => 2 }, { "foo" => 2, "bar" => 1 }, { "foo" => 3, "bar" => 3 } ].each(&block)
end
end
@@ -147,6 +147,10 @@ class StandardFiltersTest < Test::Unit::TestCase
assert_equal "123", Liquid::Template.parse('{{ foo | map: "foo" }}').render!("foo" => TestEnumerable.new)
end
def test_sort_works_on_enumerables
assert_equal "213", Liquid::Template.parse('{{ foo | sort: "bar" | 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")