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

- old
+ new

@@ -1,6 +1,6 @@ -require File.dirname(__FILE__) + '/../abstract_unit' +require 'abstract_unit' uses_mocha 'rescue' do class RescueController < ActionController::Base class NotAuthorized < StandardError @@ -277,11 +277,11 @@ templates = ActionController::Base.rescue_templates assert_equal ActionController::Rescue::DEFAULT_RESCUE_TEMPLATE, templates.default assert_equal ActionController::Rescue::DEFAULT_RESCUE_TEMPLATE, templates[Exception.new] - assert_equal 'missing_template', templates[ActionController::MissingTemplate.name] + assert_equal 'missing_template', templates[ActionView::MissingTemplate.name] assert_equal 'routing_error', templates[ActionController::RoutingError.name] assert_equal 'unknown_action', templates[ActionController::UnknownAction.name] assert_equal 'template_error', templates[ActionView::TemplateError.name] end @@ -303,19 +303,23 @@ end end 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'] end 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'] end @@ -389,18 +393,30 @@ yield ensure @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) } else Object.remove_const(:RAILS_ROOT) rescue nil end - yield + with_rails_public_path(path, &block) ensure if old_rails_root silence_warnings { Object.const_set(:RAILS_ROOT, old_rails_root) } else