Add max/min filters

This commit is contained in:
Nithin Bekal
2017-11-30 13:56:37 -05:00
parent 85b1e91aed
commit 4bdaaf069f
2 changed files with 38 additions and 0 deletions
+22
View File
@@ -498,6 +498,28 @@ class StandardFiltersTest < Minitest::Test
assert_template_result "5", "{{ price | floor }}", 'price' => NumberLikeThing.new(5.4)
end
def test_max
assert_template_result "4", "{{ 5 | max:4 }}"
assert_template_result "5", "{{ 5 | max:5 }}"
assert_template_result "5", "{{ 5 | max:6 }}"
assert_template_result "4.5", "{{ 4.5 | max:5 }}"
assert_template_result "5", "{{ width | max:5 }}", 'width' => NumberLikeThing.new(6)
assert_template_result "4", "{{ width | max:5 }}", 'width' => NumberLikeThing.new(4)
assert_template_result "4", "{{ 5 | max: width }}", 'width' => NumberLikeThing.new(4)
end
def test_min
assert_template_result "5", "{{ 5 | min:4 }}"
assert_template_result "5", "{{ 5 | min:5 }}"
assert_template_result "6", "{{ 5 | min:6 }}"
assert_template_result "5", "{{ 4.5 | min:5 }}"
assert_template_result "6", "{{ width | min:5 }}", 'width' => NumberLikeThing.new(6)
assert_template_result "5", "{{ width | min:5 }}", 'width' => NumberLikeThing.new(4)
assert_template_result "6", "{{ 5 | min: width }}", 'width' => NumberLikeThing.new(6)
end
def test_append
assigns = { 'a' => 'bc', 'b' => 'd' }
assert_template_result('bcd', "{{ a | append: 'd'}}", assigns)