diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2008-04-13 17:33:27 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2008-04-13 17:33:27 -0500 |
commit | 420c4b3d8878156d04f45e47050ddc62ae00c68c (patch) | |
tree | e56d27d2078a7553b161a1088594e147e25ed2da /actionpack/test/controller/rescue_test.rb | |
parent | be7fd8168aa4776dccfe2e670cb9451204449dd4 (diff) | |
download | rails-420c4b3d8878156d04f45e47050ddc62ae00c68c.tar.gz rails-420c4b3d8878156d04f45e47050ddc62ae00c68c.tar.bz2 rails-420c4b3d8878156d04f45e47050ddc62ae00c68c.zip |
Added Rails.public_path to control where HTML and assets are expected to be loaded from (defaults to Rails.root + "/public") #11581 [nicksieger]
Diffstat (limited to 'actionpack/test/controller/rescue_test.rb')
-rw-r--r-- | actionpack/test/controller/rescue_test.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb index 55631e0777..011992474f 100644 --- a/actionpack/test/controller/rescue_test.rb +++ b/actionpack/test/controller/rescue_test.rb @@ -305,7 +305,9 @@ class RescueTest < Test::Unit::TestCase def test_not_implemented with_all_requests_local false do - head :not_implemented + with_rails_public_path(".") do + head :not_implemented + end end assert_response :not_implemented assert_equal "GET, PUT", @response.headers['Allow'] @@ -313,7 +315,9 @@ class RescueTest < Test::Unit::TestCase def test_method_not_allowed with_all_requests_local false do - get :method_not_allowed + with_rails_public_path(".") do + get :method_not_allowed + end end assert_response :method_not_allowed assert_equal "GET, HEAD, PUT", @response.headers['Allow'] @@ -391,7 +395,19 @@ class RescueTest < Test::Unit::TestCase @request.remote_addr = old_remote_addr end - def with_rails_root(path = nil) + def with_rails_public_path(rails_root) + old_rails = Object.const_get(:Rails) rescue nil + mod = Object.const_set(:Rails, Module.new) + (class << mod; self; end).instance_eval do + define_method(:public_path) { "#{rails_root}/public" } + end + yield + ensure + Object.module_eval { remove_const(:Rails) } if defined?(Rails) + Object.const_set(:Rails, old_rails) if old_rails + end + + def with_rails_root(path = nil,&block) old_rails_root = RAILS_ROOT if defined?(RAILS_ROOT) if path silence_warnings { Object.const_set(:RAILS_ROOT, path) } @@ -399,7 +415,7 @@ class RescueTest < Test::Unit::TestCase Object.remove_const(:RAILS_ROOT) rescue nil end - yield + with_rails_public_path(path, &block) ensure if old_rails_root |