Fix Rails info controller for postgres; Closes #4469.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4097 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Nicholas Seckar 2006-03-29 15:11:47 +00:00
parent b583d23f95
commit 23fa0395d8
4 changed files with 23 additions and 23 deletions

@ -1,5 +1,9 @@
*SVN*
* Avoid passing escapeHTML non-string in Rails' info controller. [Nicholas Seckar]
* Fix Rails info controller's tests. [Nicholas Seckar]
* Added gzip compression for JavaScript, CSS, and HTML to default lighttpd.conf [DHH]

@ -51,8 +51,8 @@ def to_s
def to_html
returning table = '<table>' do
properties.each do |(name, value)|
table << %(<tr><td class="name">#{CGI.escapeHTML(name)}</td>)
table << %(<td class="value">#{CGI.escapeHTML(value)}</td></tr>)
table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
table << %(<td class="value">#{CGI.escapeHTML(value.to_s)}</td></tr>)
end
table << '</table>'
end

@ -1,11 +1,9 @@
module Rails
class InfoController < ActionController::Base
def properties
if local_request?
render :inline => Rails::Info.to_html
else
render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => 500
end
class Rails::InfoController < ActionController::Base
def properties
if local_request?
render :inline => Rails::Info.to_html
else
render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => 500
end
end
end
end

@ -1,19 +1,22 @@
$:.unshift File.dirname(__FILE__) + "/../lib"
$:.unshift File.dirname(__FILE__) + "/../builtin/controllers"
$:.unshift File.dirname(__FILE__) + "/../builtin/rails_info"
$:.unshift File.dirname(__FILE__) + "/../../actionpack/lib"
$:.unshift File.dirname(__FILE__) + "/../../activesupport/lib"
require 'test/unit'
require 'action_controller'
require 'action_controller/test_process'
require 'rails_info'
class ApplicationController < ActionController::Base
require_dependency 'rails/info_controller'
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
@ -24,27 +27,22 @@ def local_request?
map.connect ':controller/:action/:id'
end
require 'rails_info_controller'
# Re-raise errors caught by the controller.
class RailsInfoController; def rescue_action(e) raise e end; end
class RailsInfoControllerTest < Test::Unit::TestCase
class Rails::InfoControllerTest < Test::Unit::TestCase
def setup
@controller = RailsInfoController.new
@controller = Rails::InfoController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
end
def test_rails_info_properties_table_rendered_for_local_request
RailsInfoController.local_request = true
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
RailsInfoController.local_request = false
Rails::InfoController.local_request = false
get :properties
assert_tag :tag => 'p'
assert_response 500