2008-05-18 06:22:34 +02:00
|
|
|
require 'abstract_unit'
|
2007-01-22 14:43:50 +01:00
|
|
|
require 'action_controller'
|
|
|
|
require 'action_controller/test_process'
|
|
|
|
|
2007-02-09 09:04:31 +01:00
|
|
|
module Rails; end
|
|
|
|
require 'rails/info'
|
|
|
|
require 'rails/info_controller'
|
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
class Rails::InfoController < ActionController::Base
|
|
|
|
@local_request = false
|
|
|
|
class << self
|
|
|
|
cattr_accessor :local_request
|
|
|
|
end
|
|
|
|
|
|
|
|
# Re-raise errors caught by the controller.
|
|
|
|
def rescue_action(e) raise e end;
|
|
|
|
|
|
|
|
protected
|
|
|
|
def local_request?
|
|
|
|
self.class.local_request
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
ActionController::Routing::Routes.draw do |map|
|
|
|
|
map.connect ':controller/:action/:id'
|
|
|
|
end
|
|
|
|
|
2009-02-04 21:26:08 +01:00
|
|
|
class Rails::InfoControllerTest < ActionController::TestCase
|
2007-01-22 14:43:50 +01:00
|
|
|
def setup
|
|
|
|
@controller = Rails::InfoController.new
|
|
|
|
@request = ActionController::TestRequest.new
|
|
|
|
@response = ActionController::TestResponse.new
|
2008-09-07 07:54:05 +02:00
|
|
|
|
|
|
|
ActionController::Base.consider_all_requests_local = true
|
2007-01-22 14:43:50 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_rails_info_properties_table_rendered_for_local_request
|
|
|
|
Rails::InfoController.local_request = true
|
|
|
|
get :properties
|
|
|
|
assert_tag :tag => 'table'
|
|
|
|
assert_response :success
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_rails_info_properties_error_rendered_for_non_local_request
|
|
|
|
Rails::InfoController.local_request = false
|
2008-09-07 07:54:05 +02:00
|
|
|
ActionController::Base.consider_all_requests_local = false
|
|
|
|
|
2007-01-22 14:43:50 +01:00
|
|
|
get :properties
|
|
|
|
assert_tag :tag => 'p'
|
|
|
|
assert_response 500
|
|
|
|
end
|
|
|
|
end
|