mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 02:40:41 -07:00
Fix resource counting bug with respond_to?(:length)
This commit is contained in:
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user