added array sorting and mapping on properties

This commit is contained in:
James MacAulay
2008-10-28 10:36:05 -04:00
parent 3d8efe04a7
commit 36860eab57
2 changed files with 27 additions and 2 deletions
+7
View File
@@ -67,6 +67,13 @@ class StandardFiltersTest < Test::Unit::TestCase
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")
end
def test_map
assert_equal [1,2,3,4], @filters.map([{"a" => 1}, {"a" => 2}, {"a" => 3}, {"a" => 4}], 'a')
assert_template_result 'abc', "{{ ary | map:'foo' | map:'bar' }}",
'ary' => [{'foo' => {'bar' => 'a'}}, {'foo' => {'bar' => 'b'}}, {'foo' => {'bar' => 'c'}}]
end
def test_date