vendor/rails/actionpack/test/controller/view_paths_test.rb in radiant-0.6.9 vs vendor/rails/actionpack/test/controller/view_paths_test.rb in radiant-0.7.0

- old
+ new

@@ -1,6 +1,6 @@ -require File.dirname(__FILE__) + '/../abstract_unit' +require 'abstract_unit' class ViewLoadPathsTest < Test::Unit::TestCase LOAD_PATH_ROOT = File.join(File.dirname(__FILE__), '..', 'fixtures') @@ -14,54 +14,57 @@ def hello_world() end def hello_world_at_request_time() render(:action => 'hello_world') end private def add_view_path - self.class.view_paths.unshift "#{LOAD_PATH_ROOT}/override" + prepend_view_path "#{LOAD_PATH_ROOT}/override" end end class Test::SubController < ActionController::Base layout 'test/sub' def hello_world; render(:template => 'test/hello_world'); end end def setup TestController.view_paths = nil - ActionView::Base.cache_template_extensions = false - @controller = TestController.new + @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - + + @controller = TestController.new + # Following is needed in order to setup @controller.template object properly + @controller.send :initialize_template_class, @response + @controller.send :assign_shortcuts, @request, @response + # Track the last warning. @old_behavior = ActiveSupport::Deprecation.behavior @last_message = nil ActiveSupport::Deprecation.behavior = Proc.new { |message, callback| @last_message = message } end def teardown ActiveSupport::Deprecation.behavior = @old_behavior - ActionView::Base.cache_template_extensions = true end def test_template_load_path_was_set_correctly assert_equal [ LOAD_PATH_ROOT ], @controller.view_paths end def test_controller_appends_view_path_correctly - TestController.append_view_path 'foo' + @controller.append_view_path 'foo' assert_equal [LOAD_PATH_ROOT, 'foo'], @controller.view_paths - TestController.append_view_path(%w(bar baz)) + @controller.append_view_path(%w(bar baz)) assert_equal [LOAD_PATH_ROOT, 'foo', 'bar', 'baz'], @controller.view_paths end def test_controller_prepends_view_path_correctly - TestController.prepend_view_path 'baz' + @controller.prepend_view_path 'baz' assert_equal ['baz', LOAD_PATH_ROOT], @controller.view_paths - TestController.prepend_view_path(%w(foo bar)) + @controller.prepend_view_path(%w(foo bar)) assert_equal ['foo', 'bar', 'baz', LOAD_PATH_ROOT], @controller.view_paths end def test_template_appends_view_path_correctly @controller.instance_variable_set :@template, ActionView::Base.new(TestController.view_paths, {}, @controller) @@ -92,11 +95,11 @@ assert_response :success assert_equal "Hello world!", @response.body end def test_view_paths_override - TestController.view_paths.unshift "#{LOAD_PATH_ROOT}/override" + TestController.prepend_view_path "#{LOAD_PATH_ROOT}/override" get :hello_world assert_response :success assert_equal "Hello overridden world!", @response.body end @@ -132,6 +135,6 @@ C.view_paths = [] assert_nothing_raised { C.view_paths << 'c/path' } assert_equal ['c/path'], C.view_paths end -end \ No newline at end of file +end