From 1d84225ee6e426a157398ce9404e3514de258ed8 Mon Sep 17 00:00:00 2001 From: Cezary Baginski Date: Sat, 28 Mar 2009 23:53:56 +0100 Subject: [PATCH] Additional template tests that didn't pass in 2.3.2 --- .../test/fixtures/backup_files/item.html.erb | 2 + .../test/fixtures/backup_files/item.html.erb.orig | 2 + actionpack/test/template/template_test.rb | 30 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 0 deletions(-) create mode 100644 actionpack/test/fixtures/backup_files/item.html.erb create mode 100644 actionpack/test/fixtures/backup_files/item.html.erb.orig diff --git a/actionpack/test/fixtures/backup_files/item.html.erb b/actionpack/test/fixtures/backup_files/item.html.erb new file mode 100644 index 0000000..c3cc0ea --- /dev/null +++ b/actionpack/test/fixtures/backup_files/item.html.erb @@ -0,0 +1,2 @@ +OK.
+This file should be loaded instead of the item.html.erb.orig file
diff --git a/actionpack/test/fixtures/backup_files/item.html.erb.orig b/actionpack/test/fixtures/backup_files/item.html.erb.orig new file mode 100644 index 0000000..fbec485 --- /dev/null +++ b/actionpack/test/fixtures/backup_files/item.html.erb.orig @@ -0,0 +1,2 @@ +This file should not be loaded.
+item.html.erb should be loaded instead
diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb index 7caec7a..9d67539 100644 --- a/actionpack/test/template/template_test.rb +++ b/actionpack/test/template/template_test.rb @@ -22,11 +22,41 @@ class TemplateTest < Test::Unit::TestCase end end + BACKUP_EXT_VIEW_PATH = File.join(FIXTURE_LOAD_PATH,'backup_files') + ITEM1_ERB = File.join(BACKUP_EXT_VIEW_PATH, 'item.html.erb') + ITEM1_ERB_ORIG = File.join(BACKUP_EXT_VIEW_PATH, 'item.html.erb.orig') + + def test_loading_correct_templates + p = ActionView::Template::EagerPath.new(BACKUP_EXT_VIEW_PATH) + p.load! + + assert_correct_template_path ITEM1_ERB, p['item.html.erb'] + assert_correct_template_path ITEM1_ERB, p['item.html'] + assert_correct_template_path ITEM1_ERB_ORIG, p['item.html.erb.orig'] + + # 2.3.2 equivalent test that fails + #assert_equal ITEM1_ERB, e['item.html'].instance_variable_get(:@filename) + end + + def test_loading_correct_reloadable_templates + p = ActionView::ReloadableTemplate::ReloadablePath.new(BACKUP_EXT_VIEW_PATH) + + assert_correct_template_path ITEM1_ERB, p['item.html.erb'] + assert_correct_template_path ITEM1_ERB, p['item.html'] + assert_correct_template_path ITEM1_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