From cbd1a07c1c83053a802f1ddb930fe3d9e46f72fd Mon Sep 17 00:00:00 2001 From: James Reid-Smith Date: Thu, 11 Sep 2014 23:27:08 +0000 Subject: [PATCH] Removed context from read_template_file, fixed tests to match new arity --- lib/liquid/tags/include.rb | 10 +--------- test/integration/blank_test.rb | 2 +- test/integration/render_profiling_test.rb | 2 +- test/integration/tags/include_tag_test.rb | 20 ++++---------------- 4 files changed, 7 insertions(+), 27 deletions(-) diff --git a/lib/liquid/tags/include.rb b/lib/liquid/tags/include.rb index e367ac3..1f9b377 100644 --- a/lib/liquid/tags/include.rb +++ b/lib/liquid/tags/include.rb @@ -78,15 +78,7 @@ module Liquid def read_template_from_file_system(context) file_system = context.registers[:file_system] || Liquid::Template.file_system - # make read_template_file call backwards-compatible. - case file_system.method(:read_template_file).arity - when 1 - file_system.read_template_file(context[@template_name]) - when 2 - file_system.read_template_file(context[@template_name], context) - else - raise ArgumentError, "file_system.read_template_file expects two parameters: (template_name, context)" - end + file_system.read_template_file(context[@template_name]) end def pass_options diff --git a/test/integration/blank_test.rb b/test/integration/blank_test.rb index f2ff9d5..1032863 100644 --- a/test/integration/blank_test.rb +++ b/test/integration/blank_test.rb @@ -9,7 +9,7 @@ class FoobarTag < Liquid::Tag end class BlankTestFileSystem - def read_template_file(template_path, context) + def read_template_file(template_path) template_path end end diff --git a/test/integration/render_profiling_test.rb b/test/integration/render_profiling_test.rb index a64e1f4..4751eec 100644 --- a/test/integration/render_profiling_test.rb +++ b/test/integration/render_profiling_test.rb @@ -4,7 +4,7 @@ class RenderProfilingTest < Minitest::Test include Liquid class ProfilingFileSystem - def read_template_file(template_path, context) + def read_template_file(template_path) "Rendering template {% assign template_name = '#{template_path}'%}\n{{ template_name }}" end end diff --git a/test/integration/tags/include_tag_test.rb b/test/integration/tags/include_tag_test.rb index 49267f3..bcf88a5 100644 --- a/test/integration/tags/include_tag_test.rb +++ b/test/integration/tags/include_tag_test.rb @@ -1,7 +1,7 @@ require 'test_helper' class TestFileSystem - def read_template_file(template_path, context) + def read_template_file(template_path) case template_path when "product" "Product: {{ product.title }} " @@ -34,14 +34,14 @@ class TestFileSystem end class OtherFileSystem - def read_template_file(template_path, context) + def read_template_file(template_path) 'from OtherFileSystem' end end class CountingFileSystem attr_reader :count - def read_template_file(template_path, context) + def read_template_file(template_path) @count ||= 0 @count += 1 'from CountingFileSystem' @@ -125,7 +125,7 @@ class IncludeTagTest < Minitest::Test def test_recursively_included_template_does_not_produce_endless_loop infinite_file_system = Class.new do - def read_template_file(template_path, context) + def read_template_file(template_path) "-{% include 'loop' %}" end end @@ -138,18 +138,6 @@ class IncludeTagTest < Minitest::Test end - def test_backwards_compatability_support_for_overridden_read_template_file - infinite_file_system = Class.new do - def read_template_file(template_path) # testing only one argument here. - "- hi mom" - end - end - - Liquid::Template.file_system = infinite_file_system.new - - Template.parse("{% include 'hi_mom' %}").render! - end - def test_dynamically_choosen_template assert_template_result "Test123", "{% include template %}", "template" => 'Test123' assert_template_result "Test321", "{% include template %}", "template" => 'Test321'