aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/view_paths_test.rb
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-10-26 05:45:41 +0000
committerRick Olson <technoweenie@gmail.com>2007-10-26 05:45:41 +0000
commit742694e0eb1abd049aa2a4eadbc7a93591c65db4 (patch)
tree6d9f1236428db94006a7626bbf6d99d63eca5533 /actionpack/test/controller/view_paths_test.rb
parentd7aa32d5d04fc98730073523d429d9ce2547316a (diff)
downloadrails-742694e0eb1abd049aa2a4eadbc7a93591c65db4.tar.gz
rails-742694e0eb1abd049aa2a4eadbc7a93591c65db4.tar.bz2
rails-742694e0eb1abd049aa2a4eadbc7a93591c65db4.zip
Simplfy #view_paths implementation. ActionView templates get the exact object, not a dup. [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8035 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/view_paths_test.rb')
-rw-r--r--actionpack/test/controller/view_paths_test.rb24
1 files changed, 20 insertions, 4 deletions
diff --git a/actionpack/test/controller/view_paths_test.rb b/actionpack/test/controller/view_paths_test.rb
index 83c4ab23e7..5a6edf1db0 100644
--- a/actionpack/test/controller/view_paths_test.rb
+++ b/actionpack/test/controller/view_paths_test.rb
@@ -4,6 +4,8 @@ class ViewLoadPathsTest < Test::Unit::TestCase
LOAD_PATH_ROOT = File.join(File.dirname(__FILE__), '..', 'fixtures')
+ ActionController::Base.view_paths = [ LOAD_PATH_ROOT ]
+
class TestController < ActionController::Base
def self.controller_path() "test" end
def rescue_action(e) raise end
@@ -24,7 +26,7 @@ class ViewLoadPathsTest < Test::Unit::TestCase
end
def setup
- TestController.view_paths = [ LOAD_PATH_ROOT ]
+ TestController.view_paths = nil
@controller = TestController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@@ -43,6 +45,22 @@ class ViewLoadPathsTest < Test::Unit::TestCase
assert_equal [ LOAD_PATH_ROOT ], @controller.view_paths
end
+ def test_template_appends_path_correctly
+ TestController.append_view_path 'foo'
+ assert_equal [LOAD_PATH_ROOT, 'foo'], @controller.view_paths
+
+ TestController.append_view_path(%w(bar baz))
+ assert_equal [LOAD_PATH_ROOT, 'foo', 'bar', 'baz'], @controller.view_paths
+ end
+
+ def test_template_prepends_path_correctly
+ TestController.prepend_view_path 'baz'
+ assert_equal ['baz', LOAD_PATH_ROOT], @controller.view_paths
+
+ TestController.prepend_view_path(%w(foo bar))
+ assert_equal ['foo', 'bar', 'baz', LOAD_PATH_ROOT], @controller.view_paths
+ end
+
def test_view_paths
get :hello_world
assert_response :success
@@ -85,11 +103,9 @@ class ViewLoadPathsTest < Test::Unit::TestCase
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' }
+ assert_equal ['c/path'], C.view_paths
end
end \ No newline at end of file