From 00d6271d2b11a14065925529af0c1200406f8beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 9 Mar 2010 13:12:11 +0100 Subject: Clean up the API required from ActionView::Template. --- actionpack/test/lib/fixture_template.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/lib/fixture_template.rb b/actionpack/test/lib/fixture_template.rb index a7f0490984..d287fae470 100644 --- a/actionpack/test/lib/fixture_template.rb +++ b/actionpack/test/lib/fixture_template.rb @@ -7,7 +7,7 @@ module ActionView #:nodoc: private - def query(path, exts) + def query(partial, path, exts) query = Regexp.escape(path) exts.each do |ext| query << '(?:' << ext.map {|e| e && Regexp.escape(".#{e}") }.join('|') << ')' @@ -15,9 +15,11 @@ module ActionView #:nodoc: templates = [] @hash.select { |k,v| k =~ /^#{query}$/ }.each do |path, source| - templates << Template.new(source, path, *path_to_details(path)) + handler, format = extract_handler_and_format(path) + templates << Template.new(source, path, handler, + :partial => partial, :virtual_path => path, :format => format) end - templates.sort_by {|t| -t.details.values.compact.size } + templates.sort_by {|t| -t.formats.size } end end -- cgit v1.2.3 From 07cf49aadf3195db6ddefc58932efc88a6704a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 10 Mar 2010 22:11:48 +0100 Subject: Optimize and clean up how details key get expired. --- actionpack/test/template/compiled_templates_test.rb | 3 --- actionpack/test/template/render_test.rb | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'actionpack/test') diff --git a/actionpack/test/template/compiled_templates_test.rb b/actionpack/test/template/compiled_templates_test.rb index 0a3409064f..2c719757e4 100644 --- a/actionpack/test/template/compiled_templates_test.rb +++ b/actionpack/test/template/compiled_templates_test.rb @@ -14,9 +14,6 @@ class CompiledTemplatesTest < Test::Unit::TestCase assert_equal "two", render(:file => "test/render_file_with_locals_and_default.erb", :locals => { :secret => "two" }) end - # This is broken in 1.8.6 (not supported in Rails 3.0) because the cache uses a Hash - # key. Since Ruby 1.8.6 implements Hash#hash using the hash's object_id, it will never - # successfully get a cache hit here. def test_template_changes_are_not_reflected_with_cached_templates assert_equal "Hello world!", render(:file => "test/hello_world.erb") modify_template "test/hello_world.erb", "Goodbye world!" do diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index 37a3975a54..cea8ab1bce 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -33,17 +33,17 @@ module RenderTestCases end def test_render_file_with_localization - old_locale, I18n.locale = I18n.locale, :da + old_locale, @view.locale = @view.locale, :da assert_equal "Hey verden", @view.render(:file => "test/hello_world") ensure - I18n.locale = old_locale + @view.locale = old_locale end def test_render_file_with_dashed_locale - old_locale, I18n.locale = I18n.locale, :"pt-BR" + old_locale, @view.locale = @view.locale, :"pt-BR" assert_equal "Ola mundo", @view.render(:file => "test/hello_world") ensure - I18n.locale = old_locale + @view.locale = old_locale end def test_render_file_at_top_level -- cgit v1.2.3