Fix resource counting bug with respond_to?(:length)

This commit is contained in:
Florian Weingarten
2014-01-08 13:00:53 -05:00
parent 0388376925
commit c6e0c1e490
5 changed files with 25 additions and 3 deletions
+14
View File
@@ -14,6 +14,14 @@ class TemplateContextDrop < Liquid::Drop
end
end
class SomethingWithLength
def length
nil
end
liquid_methods :length
end
class TemplateTest < Test::Unit::TestCase
include Liquid
@@ -86,6 +94,12 @@ class TemplateTest < Test::Unit::TestCase
@global = nil
end
def test_resource_limits_works_with_custom_length_method
t = Template.parse("{% assign foo = bar %}")
t.resource_limits = { :render_length_limit => 42 }
assert_equal "", t.render("bar" => SomethingWithLength.new)
end
def test_resource_limits_render_length
t = Template.parse("0123456789")
t.resource_limits = { :render_length_limit => 5 }