mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-16 17:30:43 -07:00
Merge branch 'master' into fix-constants
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'test_helper'
|
||||
|
||||
class DisabledTagsTest < Minitest::Test
|
||||
include Liquid
|
||||
|
||||
class DisableRaw < Block
|
||||
disable_tags "raw"
|
||||
end
|
||||
|
||||
class DisableRawEcho < Block
|
||||
disable_tags "raw", "echo"
|
||||
end
|
||||
|
||||
def test_disables_raw
|
||||
with_custom_tag('disable', DisableRaw) do
|
||||
assert_template_result 'raw usage is not allowed in this contextfoo', '{% disable %}{% raw %}Foobar{% endraw %}{% echo "foo" %}{% enddisable %}'
|
||||
end
|
||||
end
|
||||
|
||||
def test_disables_echo_and_raw
|
||||
with_custom_tag('disable', DisableRawEcho) do
|
||||
assert_template_result 'raw usage is not allowed in this contextecho usage is not allowed in this context', '{% disable %}{% raw %}Foobar{% endraw %}{% echo "foo" %}{% enddisable %}'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -89,14 +89,12 @@ class RenderTagTest < Minitest::Test
|
||||
end
|
||||
end
|
||||
|
||||
def test_includes_and_renders_count_towards_the_same_recursion_limit
|
||||
def test_sub_contexts_count_towards_the_same_recursion_limit
|
||||
Liquid::Template.file_system = StubFileSystem.new(
|
||||
'loop_render' => '{% render "loop_include" %}',
|
||||
'loop_include' => '{% include "loop_render" %}'
|
||||
'loop_render' => '{% render "loop_render" %}',
|
||||
)
|
||||
|
||||
assert_raises Liquid::StackLevelError do
|
||||
Template.parse('{% render "loop_include" %}').render!
|
||||
assert_raises Liquid::StackLevelError do
|
||||
Template.parse('{% render "loop_render" %}').render!
|
||||
end
|
||||
end
|
||||
|
||||
@@ -148,4 +146,23 @@ class RenderTagTest < Minitest::Test
|
||||
Liquid::Template.file_system = StubFileSystem.new('decr' => '{% decrement %}')
|
||||
assert_template_result '-1-2-1', '{% decrement %}{% decrement %}{% render "decr" %}'
|
||||
end
|
||||
|
||||
def test_includes_will_not_render_inside_render_tag
|
||||
Liquid::Template.file_system = StubFileSystem.new(
|
||||
'foo' => 'bar',
|
||||
'test_include' => '{% include "foo" %}'
|
||||
)
|
||||
|
||||
assert_template_result 'include usage is not allowed in this context', '{% render "test_include" %}'
|
||||
end
|
||||
|
||||
def test_includes_will_not_render_inside_nested_sibling_tags
|
||||
Liquid::Template.file_system = StubFileSystem.new(
|
||||
'foo' => 'bar',
|
||||
'nested_render_with_sibling_include' => '{% render "test_include" %}{% include "foo" %}',
|
||||
'test_include' => '{% include "foo" %}'
|
||||
)
|
||||
|
||||
assert_template_result 'include usage is not allowed in this contextinclude usage is not allowed in this context', '{% render "nested_render_with_sibling_include" %}'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user