1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge branch 'master' into testing

This commit is contained in:
Jeremy Kemper 2008-11-08 18:58:29 -05:00
commit ace9e533dc
4 changed files with 66 additions and 8 deletions

View file

@ -0,0 +1,46 @@
require 'abstract_unit'
class LoggingController < ActionController::Base
def show
render :nothing => true
end
end
class LoggingTest < ActionController::TestCase
tests LoggingController
class MockLogger
attr_reader :logged
def method_missing(method, *args)
@logged ||= []
@logged << args.first
end
end
setup :set_logger
def test_logging_without_parameters
get :show
assert_equal 2, logs.size
assert_nil logs.detect {|l| l =~ /Parameters/ }
end
def test_logging_with_parameters
get :show, :id => 10
assert_equal 3, logs.size
params = logs.detect {|l| l =~ /Parameters/ }
assert_equal 'Parameters: {"id"=>"10"}', params
end
private
def set_logger
@controller.logger = MockLogger.new
end
def logs
@logs ||= @controller.logger.logged.compact.map {|l| l.strip}
end
end

View file

@ -65,15 +65,23 @@ module ActiveRecord
# The default ConnectionPool maximum size is 5.
def initialize(spec)
@spec = spec
# The cache of reserved connections mapped to threads
@reserved_connections = {}
# The mutex used to synchronize pool access
@connection_mutex = Monitor.new
@queue = @connection_mutex.new_cond
# default 5 second timeout
@timeout = spec.config[:wait_timeout] || 5
# default 5 second timeout unless on ruby 1.9
@timeout =
if RUBY_VERSION < '1.9'
spec.config[:wait_timeout] || 5
end
# default max pool size to 5
@size = (spec.config[:pool] && spec.config[:pool].to_i) || 5
@connections = []
@checked_out = []
end
@ -187,7 +195,7 @@ module ActiveRecord
# try looting dead threads
clear_stale_cached_connections!
if @size == @checked_out.size
raise ConnectionTimeoutError, "could not obtain a database connection within #{@timeout} seconds. The pool size is currently #{@size}, perhaps you need to increase it?"
raise ConnectionTimeoutError, "could not obtain a database connection#{" within #{@timeout} seconds" if @timeout}. The max pool size is currently #{@size}; consider increasing it."
end
end
end

View file

@ -28,10 +28,13 @@ class PooledConnectionsTest < ActiveRecord::TestCase
end
end
def test_pooled_connection_checkout
checkout_connections
assert_equal @connections.length, 2
assert_equal @timed_out, 2
# Will deadlock due to lack of Monitor timeouts in 1.9
if RUBY_VERSION < '1.9'
def test_pooled_connection_checkout
checkout_connections
assert_equal @connections.length, 2
assert_equal @timed_out, 2
end
end
def checkout_checkin_connections(pool_size, threads)

View file

@ -1,7 +1,6 @@
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/gempackagetask'
require 'rake/contrib/sshpublisher'
require File.join(File.dirname(__FILE__), 'lib', 'active_support', 'version')
@ -65,12 +64,14 @@ end
desc "Publish the beta gem"
task :pgem => [:package] do
require 'rake/contrib/sshpublisher'
Rake::SshFilePublisher.new("gems.rubyonrails.org", "/u/sites/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
`ssh gems.rubyonrails.org '/u/sites/gems/gemupdate.sh'`
end
desc "Publish the API documentation"
task :pdoc => [:rdoc] do
require 'rake/contrib/sshpublisher'
Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/as", "doc").upload
end