aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/activerecord/pagination_test.rb2
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb2
-rw-r--r--actionpack/test/controller/addresses_render_test.rb2
-rw-r--r--actionpack/test/controller/capture_test.rb2
-rw-r--r--actionpack/test/controller/content_type_test.rb2
-rw-r--r--actionpack/test/controller/deprecation/deprecated_base_methods_test.rb2
-rw-r--r--actionpack/test/controller/layout_test.rb12
-rw-r--r--actionpack/test/controller/mime_responds_test.rb2
-rw-r--r--actionpack/test/controller/new_render_test.rb4
-rw-r--r--actionpack/test/controller/render_test.rb4
-rw-r--r--actionpack/test/controller/send_file_test.rb2
-rw-r--r--actionpack/test/controller/view_paths_test.rb78
-rw-r--r--actionpack/test/fixtures/override/test/hello_world.rhtml1
-rw-r--r--actionpack/test/template/deprecated_instance_variables_test.rb2
-rw-r--r--actionpack/test/template/url_helper_test.rb4
15 files changed, 101 insertions, 20 deletions
diff --git a/actionpack/test/activerecord/pagination_test.rb b/actionpack/test/activerecord/pagination_test.rb
index ddd2cec8b3..49f153e26e 100644
--- a/actionpack/test/activerecord/pagination_test.rb
+++ b/actionpack/test/activerecord/pagination_test.rb
@@ -4,7 +4,7 @@ class PaginationTest < ActiveRecordTestCase
fixtures :topics, :replies, :developers, :projects, :developers_projects
class PaginationController < ActionController::Base
- self.template_root = "#{File.dirname(__FILE__)}/../fixtures/"
+ self.view_paths = [ "#{File.dirname(__FILE__)}/../fixtures/" ]
def simple_paginate
@topic_pages, @topics = paginate(:topics)
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index d9cfe18ae5..f9a641a1ec 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -152,7 +152,7 @@ end
# tell the controller where to find its templates but start from parent
# directory of test_request_response to simulate the behaviour of a
# production environment
-ActionPackAssertionsController.template_root = File.dirname(__FILE__) + "/../fixtures/"
+ActionPackAssertionsController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
# a test case to exercise the new capabilities TestRequest & TestResponse
class ActionPackAssertionsControllerTest < Test::Unit::TestCase
diff --git a/actionpack/test/controller/addresses_render_test.rb b/actionpack/test/controller/addresses_render_test.rb
index 4de1c80505..6c5424a5b6 100644
--- a/actionpack/test/controller/addresses_render_test.rb
+++ b/actionpack/test/controller/addresses_render_test.rb
@@ -22,7 +22,7 @@ class AddressesTestController < ActionController::Base
def self.controller_path; "addresses"; end
end
-AddressesTestController.template_root = File.dirname(__FILE__) + "/../fixtures/"
+AddressesTestController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
class AddressesTest < Test::Unit::TestCase
def setup
diff --git a/actionpack/test/controller/capture_test.rb b/actionpack/test/controller/capture_test.rb
index 43bf346eef..300bdc3a84 100644
--- a/actionpack/test/controller/capture_test.rb
+++ b/actionpack/test/controller/capture_test.rb
@@ -23,7 +23,7 @@ class CaptureController < ActionController::Base
def rescue_action(e) raise end
end
-CaptureController.template_root = File.dirname(__FILE__) + "/../fixtures/"
+CaptureController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
class CaptureTest < Test::Unit::TestCase
def setup
diff --git a/actionpack/test/controller/content_type_test.rb b/actionpack/test/controller/content_type_test.rb
index 6f0618da0e..1841d37c0b 100644
--- a/actionpack/test/controller/content_type_test.rb
+++ b/actionpack/test/controller/content_type_test.rb
@@ -45,7 +45,7 @@ class ContentTypeController < ActionController::Base
def rescue_action(e) raise end
end
-ContentTypeController.template_root = File.dirname(__FILE__) + "/../fixtures/"
+ContentTypeController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
class ContentTypeTest < Test::Unit::TestCase
def setup
diff --git a/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb b/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb
index d8da676f96..3256b77477 100644
--- a/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb
+++ b/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb
@@ -21,7 +21,7 @@ class DeprecatedBaseMethodsTest < Test::Unit::TestCase
def rescue_action(e) raise e end
end
- Target.template_root = File.dirname(__FILE__) + "/../../fixtures"
+ Target.view_paths = [ File.dirname(__FILE__) + "/../../fixtures" ]
def setup
@request = ActionController::TestRequest.new
diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb
index 9338bfa6f9..cade6738a7 100644
--- a/actionpack/test/controller/layout_test.rb
+++ b/actionpack/test/controller/layout_test.rb
@@ -1,15 +1,17 @@
require File.dirname(__FILE__) + '/../abstract_unit'
-# The template_root must be set on Base and not LayoutTest so that LayoutTest's inherited method has access to
-# the template_root when looking for a layout
-ActionController::Base.template_root = File.dirname(__FILE__) + '/../fixtures/layout_tests/'
+# The view_paths array must be set on Base and not LayoutTest so that LayoutTest's inherited
+# method has access to the view_paths array when looking for a layout to automatically assign.
+old_load_paths = ActionController::Base.view_paths
+ActionController::Base.view_paths = [ File.dirname(__FILE__) + '/../fixtures/layout_tests/' ]
class LayoutTest < ActionController::Base
def self.controller_path; 'views' end
+ self.view_paths = ActionController::Base.view_paths.dup
end
-# Restore template root to be unset
-ActionController::Base.template_root = nil
+# Restore view_paths to previous value
+ActionController::Base.view_paths = old_load_paths
class ProductController < LayoutTest
end
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index 5692d26232..3a1df02a7f 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -118,7 +118,7 @@ class RespondToController < ActionController::Base
end
end
-RespondToController.template_root = File.dirname(__FILE__) + "/../fixtures/"
+RespondToController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
class MimeControllerTest < Test::Unit::TestCase
def setup
diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb
index 9b328e2c0a..70bb18cadc 100644
--- a/actionpack/test/controller/new_render_test.rb
+++ b/actionpack/test/controller/new_render_test.rb
@@ -350,8 +350,8 @@ class NewRenderTestController < ActionController::Base
end
end
-NewRenderTestController.template_root = File.dirname(__FILE__) + "/../fixtures/"
-Fun::GamesController.template_root = File.dirname(__FILE__) + "/../fixtures/"
+NewRenderTestController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
+Fun::GamesController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
class NewRenderTest < Test::Unit::TestCase
def setup
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index d364dd6c93..bf9042ec7a 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -134,8 +134,8 @@ class TestController < ActionController::Base
end
end
-TestController.template_root = File.dirname(__FILE__) + "/../fixtures/"
-Fun::GamesController.template_root = File.dirname(__FILE__) + "/../fixtures/"
+TestController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
+Fun::GamesController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
class RenderTest < Test::Unit::TestCase
def setup
diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb
index 83590fd73e..e7ebc91676 100644
--- a/actionpack/test/controller/send_file_test.rb
+++ b/actionpack/test/controller/send_file_test.rb
@@ -21,7 +21,7 @@ class SendFileController < ActionController::Base
def rescue_action(e) raise end
end
-SendFileController.template_root = File.dirname(__FILE__) + "/../fixtures/"
+SendFileController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
class SendFileTest < Test::Unit::TestCase
include TestFileUtils
diff --git a/actionpack/test/controller/view_paths_test.rb b/actionpack/test/controller/view_paths_test.rb
new file mode 100644
index 0000000000..9184ab1793
--- /dev/null
+++ b/actionpack/test/controller/view_paths_test.rb
@@ -0,0 +1,78 @@
+require File.dirname(__FILE__) + '/../abstract_unit'
+
+class ViewLoadPathsTest < Test::Unit::TestCase
+
+ LOAD_PATH_ROOT = File.join(File.dirname(__FILE__), '..', 'fixtures')
+
+ class TestController < ActionController::Base
+ def self.controller_path() "test" end
+ def rescue_action(e) raise end
+
+ def hello_world() end
+ end
+
+ def setup
+ TestController.view_paths = [ LOAD_PATH_ROOT ]
+ @controller = TestController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+
+ # Track the last warning.
+ @old_behavior = ActiveSupport::Deprecation.behavior
+ @last_message = nil
+ ActiveSupport::Deprecation.behavior = Proc.new { |message| @last_message = message }
+ end
+
+ def teardown
+ ActiveSupport::Deprecation.behavior = @old_behavior
+ end
+
+ def test_template_load_path_was_set_correctly
+ assert_equal [ LOAD_PATH_ROOT ], @controller.view_paths
+ end
+
+ def test_view_paths
+ get :hello_world
+ assert_response :success
+ assert_equal "Hello world!", @response.body
+ end
+
+ def test_view_paths_override
+ TestController.view_paths.unshift "#{LOAD_PATH_ROOT}/override"
+ get :hello_world
+ assert_response :success
+ assert_equal "Hello overridden world!", @response.body
+ end
+
+ def test_template_root_deprecated
+ assert_deprecated(/template_root.*view_paths/) do
+ TestController.template_root = LOAD_PATH_ROOT
+ end
+ assert_deprecated(/template_root.*view_paths/) do
+ assert_equal LOAD_PATH_ROOT, TestController.template_root
+ end
+ end
+
+ def test_inheritance
+ original_load_paths = ActionController::Base.view_paths
+
+ self.class.class_eval %{
+ class A < ActionController::Base; end
+ class B < A; end
+ class C < ActionController::Base; end
+ }
+
+ A.view_paths = [ 'a/path' ]
+
+ assert_equal [ 'a/path' ], A.view_paths
+ assert_equal A.view_paths, B.view_paths
+ assert_equal original_load_paths, C.view_paths
+
+ e = assert_raises(TypeError) { C.view_paths << 'c/path' }
+ assert_equal "can't modify frozen array", e.message
+
+ C.view_paths = []
+ assert_nothing_raised { C.view_paths << 'c/path' }
+ end
+
+end \ No newline at end of file
diff --git a/actionpack/test/fixtures/override/test/hello_world.rhtml b/actionpack/test/fixtures/override/test/hello_world.rhtml
new file mode 100644
index 0000000000..3e308d3d86
--- /dev/null
+++ b/actionpack/test/fixtures/override/test/hello_world.rhtml
@@ -0,0 +1 @@
+Hello overridden world! \ No newline at end of file
diff --git a/actionpack/test/template/deprecated_instance_variables_test.rb b/actionpack/test/template/deprecated_instance_variables_test.rb
index 3a8d620b34..d3cffbc1e9 100644
--- a/actionpack/test/template/deprecated_instance_variables_test.rb
+++ b/actionpack/test/template/deprecated_instance_variables_test.rb
@@ -2,7 +2,7 @@ require "#{File.dirname(__FILE__)}/../abstract_unit"
class DeprecatedViewInstanceVariablesTest < Test::Unit::TestCase
class DeprecatedInstanceVariablesController < ActionController::Base
- self.template_root = "#{File.dirname(__FILE__)}/../fixtures/"
+ self.view_paths = [ "#{File.dirname(__FILE__)}/../fixtures/" ]
def self.controller_path; 'deprecated_instance_variables' end
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb
index 6080275379..8cef4ffe14 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionpack/test/template/url_helper_test.rb
@@ -250,7 +250,7 @@ end
class UrlHelperWithControllerTest < Test::Unit::TestCase
class UrlHelperController < ActionController::Base
- self.template_root = "#{File.dirname(__FILE__)}/../fixtures/"
+ self.view_paths = [ "#{File.dirname(__FILE__)}/../fixtures/" ]
def self.controller_path; 'url_helper_with_controller' end
@@ -305,7 +305,7 @@ end
class LinkToUnlessCurrentWithControllerTest < Test::Unit::TestCase
class TasksController < ActionController::Base
- self.template_root = "#{File.dirname(__FILE__)}/../fixtures/"
+ self.view_paths = ["#{File.dirname(__FILE__)}/../fixtures/"]
def self.controller_path; 'tasks' end