From 4d910b033379727e5e7355590c50c72fc75e56db Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 26 Nov 2008 20:54:47 -0600 Subject: Super lazy load view paths in development mode (no indexing or caching at all). Switch layout finders to use view path api to take advantage of cache. --- actionpack/test/template/compiled_templates_test.rb | 9 --------- actionpack/test/template/render_test.rb | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 11 deletions(-) (limited to 'actionpack/test/template') diff --git a/actionpack/test/template/compiled_templates_test.rb b/actionpack/test/template/compiled_templates_test.rb index f7688b2072..0b3d039409 100644 --- a/actionpack/test/template/compiled_templates_test.rb +++ b/actionpack/test/template/compiled_templates_test.rb @@ -30,15 +30,6 @@ uses_mocha 'TestTemplateRecompilation' do assert_equal "Hello world!", render(:file => "test/hello_world.erb") end - def test_compiled_template_will_always_be_recompiled_when_eager_loaded_templates_is_off - ActionView::PathSet::Path.expects(:eager_load_templates?).times(4).returns(false) - assert_equal 0, @compiled_templates.instance_methods.size - assert_equal "Hello world!", render(:file => "#{FIXTURE_LOAD_PATH}/test/hello_world.erb") - ActionView::Template.any_instance.expects(:compile!).times(3) - 3.times { assert_equal "Hello world!", render(:file => "#{FIXTURE_LOAD_PATH}/test/hello_world.erb") } - assert_equal 1, @compiled_templates.instance_methods.size - end - private def render(*args) ActionView::Base.new(ActionController::Base.view_paths, {}).render(*args) diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index b316d5c23e..28d38b0c76 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -4,7 +4,9 @@ require 'controller/fake_models' class ViewRenderTest < Test::Unit::TestCase def setup @assigns = { :secret => 'in the sauce' } - @view = ActionView::Base.new(ActionController::Base.view_paths, @assigns) + view_paths = ActionController::Base.view_paths + @view = ActionView::Base.new(view_paths, @assigns) + assert view_paths.first.loaded? end def test_render_file @@ -157,7 +159,7 @@ class ViewRenderTest < Test::Unit::TestCase end def test_render_fallbacks_to_erb_for_unknown_types - assert_equal "Hello, World!", @view.render(:inline => "Hello, World!", :type => :foo) + assert_equal "Hello, World!", @view.render(:inline => "Hello, World!", :type => :bar) end CustomHandler = lambda do |template| @@ -196,3 +198,14 @@ class ViewRenderTest < Test::Unit::TestCase @view.render(:file => "test/nested_layout.erb", :layout => "layouts/yield") end end + +class LazyViewRenderTest < ViewRenderTest + # Test the same thing as above, but make sure the view path + # is not eager loaded + def setup + @assigns = { :secret => 'in the sauce' } + view_paths = ActionView::Base.process_view_paths(FIXTURE_LOAD_PATH) + @view = ActionView::Base.new(view_paths, @assigns) + assert !view_paths.first.loaded? + end +end -- cgit v1.2.3