diff options
author | thedarkone <thedarkone2@gmail.com> | 2009-03-24 10:48:47 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-03-24 10:54:18 -0500 |
commit | ae9f258e03c9fd5088da12c1c6cd216cc89a01f7 (patch) | |
tree | f9abd9c79ba8d8697712f58049abf655a1cf1e51 /actionpack/test/template | |
parent | e3b166aab37ddc2fbab030b146eb61713b91bf55 (diff) | |
download | rails-ae9f258e03c9fd5088da12c1c6cd216cc89a01f7.tar.gz rails-ae9f258e03c9fd5088da12c1c6cd216cc89a01f7.tar.bz2 rails-ae9f258e03c9fd5088da12c1c6cd216cc89a01f7.zip |
Fix template extension parsing. [#2315 state:resolved] [#2284 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'actionpack/test/template')
-rw-r--r-- | actionpack/test/template/template_test.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb new file mode 100644 index 0000000000..7caec7ad9f --- /dev/null +++ b/actionpack/test/template/template_test.rb @@ -0,0 +1,32 @@ +require 'abstract_unit' + +class TemplateTest < Test::Unit::TestCase + def test_template_path_parsing + with_options :base_path => nil, :name => 'abc', :locale => nil, :format => 'html', :extension => 'erb' do |t| + t.assert_parses_template_path 'abc.en.html.erb', :locale => 'en' + t.assert_parses_template_path 'abc.en.plain.html.erb', :locale => 'en', :format => 'plain.html' + t.assert_parses_template_path 'abc.html.erb' + t.assert_parses_template_path 'abc.plain.html.erb', :format => 'plain.html' + t.assert_parses_template_path 'abc.erb', :format => nil + t.assert_parses_template_path 'abc.html', :extension => nil + + t.assert_parses_template_path '_abc.html.erb', :name => '_abc' + + t.assert_parses_template_path 'test/abc.html.erb', :base_path => 'test' + t.assert_parses_template_path './test/abc.html.erb', :base_path => './test' + t.assert_parses_template_path '../test/abc.html.erb', :base_path => '../test' + + t.assert_parses_template_path 'abc', :extension => nil, :format => nil, :name => nil + t.assert_parses_template_path 'abc.xxx', :extension => nil, :format => 'xxx', :name => 'abc' + t.assert_parses_template_path 'abc.html.xxx', :extension => nil, :format => 'xxx', :name => 'abc' + end + end + + private + def assert_parses_template_path(path, parse_results) + template = ActionView::Template.new(path, '') + parse_results.each_pair do |k, v| + assert_block(%Q{Expected template to parse #{k.inspect} from "#{path}" as #{v.inspect}, but got #{template.send(k).inspect}}) { v == template.send(k) } + end + end +end |