add name attribute to Template for more flexibility to set context's template name

This commit is contained in:
Michael Go
2023-02-27 17:11:52 -04:00
parent 0fe4a5d144
commit 428c66ffac
6 changed files with 15 additions and 14 deletions
+4 -2
View File
@@ -268,12 +268,14 @@ class RenderTagTest < Minitest::Test
def test_render_tag_renders_actual_template_name_for_error
original_file_system = Liquid::Template.file_system
Liquid::Template.file_system = MemoryFileSystem.new(
context = Liquid::Context.new('errors' => ErrorDrop.new)
context.registers[:file_system] = MemoryFileSystem.new(
'/some/path/snippets/foo.liquid' => "{{ foo.standard_error }}",
)
template = Liquid::Template.parse("{% render 'foo' with errors %}", line_numbers: true)
assert_equal('Liquid error (/some/path/snippets/foo line 1): standard error', template.render('errors' => ErrorDrop.new))
assert_equal('Liquid error (/some/path/snippets/foo line 1): standard error', template.render(context))
ensure
Liquid::Template.file_system = original_file_system
end