2008-01-05 08:33:00 -05:00
|
|
|
require 'abstract_unit'
|
2005-11-07 23:26:34 -05:00
|
|
|
require 'action_controller'
|
|
|
|
require 'action_controller/test_process'
|
|
|
|
|
2006-08-29 06:40:11 -04:00
|
|
|
module Rails; end
|
2006-09-02 20:04:20 -04:00
|
|
|
require 'rails/info'
|
|
|
|
require 'rails/info_controller'
|
|
|
|
|
2006-03-29 10:11:47 -05:00
|
|
|
class Rails::InfoController < ActionController::Base
|
2005-11-07 23:26:34 -05:00
|
|
|
@local_request = false
|
|
|
|
class << self
|
|
|
|
cattr_accessor :local_request
|
|
|
|
end
|
|
|
|
|
2006-03-29 10:11:47 -05:00
|
|
|
# Re-raise errors caught by the controller.
|
|
|
|
def rescue_action(e) raise e end;
|
|
|
|
|
2005-11-07 23:26:34 -05:00
|
|
|
protected
|
|
|
|
def local_request?
|
|
|
|
self.class.local_request
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
ActionController::Routing::Routes.draw do |map|
|
|
|
|
map.connect ':controller/:action/:id'
|
|
|
|
end
|
|
|
|
|
2006-03-29 10:11:47 -05:00
|
|
|
class Rails::InfoControllerTest < Test::Unit::TestCase
|
2005-11-07 23:26:34 -05:00
|
|
|
def setup
|
2006-03-29 10:11:47 -05:00
|
|
|
@controller = Rails::InfoController.new
|
2005-11-07 23:26:34 -05:00
|
|
|
@request = ActionController::TestRequest.new
|
|
|
|
@response = ActionController::TestResponse.new
|
2008-06-05 15:41:22 -04:00
|
|
|
|
|
|
|
ActionController::Base.consider_all_requests_local = true
|
2005-11-07 23:26:34 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_rails_info_properties_table_rendered_for_local_request
|
2006-03-29 10:11:47 -05:00
|
|
|
Rails::InfoController.local_request = true
|
2005-11-07 23:26:34 -05:00
|
|
|
get :properties
|
|
|
|
assert_tag :tag => 'table'
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_rails_info_properties_error_rendered_for_non_local_request
|
2006-03-29 10:11:47 -05:00
|
|
|
Rails::InfoController.local_request = false
|
2008-06-05 15:41:22 -04:00
|
|
|
ActionController::Base.consider_all_requests_local = false
|
|
|
|
|
2005-11-07 23:26:34 -05:00
|
|
|
get :properties
|
|
|
|
assert_tag :tag => 'p'
|
|
|
|
assert_response 500
|
|
|
|
end
|
|
|
|
end
|