From 63836af2ed52cd5746bd8536cc8fc6c86f2ed71d Mon Sep 17 00:00:00 2001 From: Cezary Baginski Date: Sat, 28 Mar 2009 13:57:48 +0100 Subject: [PATCH] Additional template tests that didn't pass in 2.3.2 --- actionpack/test/template/template_test.rb | 35 +++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb index 7caec7a..8353b8a 100644 --- a/actionpack/test/template/template_test.rb +++ b/actionpack/test/template/template_test.rb @@ -22,11 +22,46 @@ class TemplateTest < Test::Unit::TestCase end end + def test_loading_correct_templates + Dir.stubs(:glob).returns(['/some/view/item.html.erb', '/some/view/item.html.erb.orig']) + File.stubs(:read).returns('some file contents') + + p = ActionView::Template::EagerPath.new('/some/view') + p.load! + + assert_correct_template_path '/some/view/item.html.erb', p['item.html.erb'] + assert_correct_template_path '/some/view/item.html.erb', p['item.html'] + assert_correct_template_path '/some/view/item.html.erb.orig', p['item.html.erb.orig'] + + # 2.3.2 equivalent test that fails + #assert_equal '/some/view/item.html.erb', e['item.html'].instance_variable_get(:@filename) + end + + def test_loading_correct_reloadable_templates + Dir.stubs(:glob).returns(['/some/view/item.html.erb', '/some/view/item.html.erb.orig']) + File.stubs(:file?).returns(true) + File.stubs(:mtime).returns(Time.now) + + p = ActionView::ReloadableTemplate::ReloadablePath.new('/some/view') + + assert_correct_template_path '/some/view/item.html.erb', p['item.html.erb'] + assert_correct_template_path '/some/view/item.html.erb', p['item.html'] + assert_correct_template_path '/some/view/item.html.erb.orig', p['item.html.erb.orig'] + 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 + + def assert_correct_template_path(expected, actual_template) + assert_equal expected, actual_template.instance_variable_get(:@_memoized_filename).first + end + end -- 1.5.6.3