提交 155eb47c 编写于 作者: M Michael Koziarski

Tests and fix for extension extraction. References #10130 [tarmo]


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8187 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 9afbf875
......@@ -516,8 +516,7 @@ def find_template_extension_from_handler(template_path, formatted = nil)
# Determine the template extension from the <tt>@first_render</tt> filename
def find_template_extension_from_first_render
extension = @first_render.to_s.sub /^\w+\.?/, ''
extension.blank? ? nil : extension
File.basename(@first_render.to_s)[/^[^.]+\.(.+)$/, 1]
end
# This method reads a template file.
......
require File.dirname(__FILE__) + '/abstract_unit'
require 'test/unit'
class ActionViewTests < Test::Unit::TestCase
def test_find_template_extension_from_first_render
base = ActionView::Base.new
assert_nil base.send(:find_template_extension_from_first_render)
{
nil => nil,
'' => nil,
'foo' => nil,
'/foo' => nil,
'foo.rb' => 'rb',
'foo.bar.rb' => 'bar.rb',
'baz/foo.rb' => 'rb',
'baz/foo.bar.rb' => 'bar.rb',
'baz/foo.o/foo.rb' => 'rb',
'baz/foo.o/foo.bar.rb' => 'bar.rb',
}.each do |input,expectation|
base.instance_variable_set('@first_render', input)
assert_equal expectation, base.send(:find_template_extension_from_first_render)
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册