mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Merge old Shopify/liquid
This commit is contained in:
+547
-547
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@ class FileSystemTest < Test::Unit::TestCase
|
||||
|
||||
def test_default
|
||||
assert_raise(FileSystemError) do
|
||||
BlankFileSystem.new.read_template_file({'dummy'=>'smarty'}, "dummy")
|
||||
BlankFileSystem.new.read_template_file("dummy", {'dummy'=>'smarty'})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TestFileSystem
|
||||
def read_template_file(context, template_name)
|
||||
template_path = context[template_name]
|
||||
def read_template_file(template_path, context)
|
||||
case template_path
|
||||
when "product"
|
||||
"Product: {{ product.title }} "
|
||||
@@ -35,8 +34,7 @@ class TestFileSystem
|
||||
end
|
||||
|
||||
class OtherFileSystem
|
||||
def read_template_file(context, template_name)
|
||||
template_path = context[template_name]
|
||||
def read_template_file(template_path, context)
|
||||
'from OtherFileSystem'
|
||||
end
|
||||
end
|
||||
@@ -106,7 +104,7 @@ class IncludeTagTest < Test::Unit::TestCase
|
||||
def test_recursively_included_template_does_not_produce_endless_loop
|
||||
|
||||
infinite_file_system = Class.new do
|
||||
def read_template_file(context, template_name)
|
||||
def read_template_file(template_path, context)
|
||||
"-{% include 'loop' %}"
|
||||
end
|
||||
end
|
||||
@@ -119,6 +117,18 @@ class IncludeTagTest < Test::Unit::TestCase
|
||||
|
||||
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_equal "Test123", Template.parse("{% include template %}").render("template" => 'Test123')
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
require 'test_helper'
|
||||
|
||||
class RawTest < Test::Unit::TestCase
|
||||
include Liquid
|
||||
|
||||
def test_tag_in_raw
|
||||
assert_template_result '{% comment %} test {% endcomment %}',
|
||||
'{% raw %}{% comment %} test {% endcomment %}{% endraw %}'
|
||||
end
|
||||
|
||||
def test_output_in_raw
|
||||
assert_template_result '{{ test }}',
|
||||
'{% raw %}{{ test }}{% endraw %}'
|
||||
end
|
||||
end
|
||||
+5
-1
@@ -7,7 +7,11 @@ require 'test/unit'
|
||||
require 'test/unit/assertions'
|
||||
require 'caller'
|
||||
require 'breakpoint'
|
||||
require 'ruby-debug'
|
||||
begin
|
||||
require 'ruby-debug'
|
||||
rescue LoadError
|
||||
puts "Couldn't load ruby-debug. gem install ruby-debug if you need it."
|
||||
end
|
||||
require File.join(File.dirname(__FILE__), '..', 'lib', 'liquid')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user