aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/render_test.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-09-02 18:21:36 +0200
committerJeremy Kemper <jeremy@bitsweat.net>2008-09-02 18:32:54 +0200
commit6f932b4790371e548c0df9033da96b2cf8f51dcc (patch)
treeb62c70a90a1716f49df5630e14ef1d847e7a7138 /actionpack/test/controller/render_test.rb
parent300754509b6990b387b056c122e90f50a79eeb81 (diff)
parentebfa43c423ac16bb699424d8d3db11855dd79a91 (diff)
downloadrails-6f932b4790371e548c0df9033da96b2cf8f51dcc.tar.gz
rails-6f932b4790371e548c0df9033da96b2cf8f51dcc.tar.bz2
rails-6f932b4790371e548c0df9033da96b2cf8f51dcc.zip
Database connections are now pooled, one pool per #establish_connection call.
Pools start out empty and grow as necessary to a maximum size (default is 5, configure size with key 'pool' in your database configuration). If no connections are available, a thread will wait up to a 'wait_timeout' time (default is 5 seconds). Connections are verified and reset when checked out from the pool (usually upon first access to ActiveRecord::Base.connection), and returned back to the pool after each request. If you would like to use connection pools outside of ActionPack, there is an ActiveRecord::Base.connection_pool method that gives you access to the pool, and you can manually checkout/checkin connections, or supply a block to ActiveRecord::Base.connection_pool.with_connection which takes care of the checkout/checkin for you. [#936 state:resolved]
Diffstat (limited to 'actionpack/test/controller/render_test.rb')
-rw-r--r--actionpack/test/controller/render_test.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index e383fda384..c4a2bf3db3 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -8,6 +8,18 @@ module Fun
end
end
+class MockLogger
+ attr_reader :logged
+
+ def initialize
+ @logged = []
+ end
+
+ def method_missing(method, *args)
+ @logged << args.first
+ end
+end
+
class TestController < ActionController::Base
class LabellingFormBuilder < ActionView::Helpers::FormBuilder
end
@@ -371,6 +383,12 @@ class TestController < ActionController::Base
end
end
+ def update_page_with_view_method
+ render :update do |page|
+ page.replace_html 'person', pluralize(2, 'person')
+ end
+ end
+
def action_talk_to_layout
# Action template sets variable that's picked up by layout
end
@@ -1022,6 +1040,13 @@ class RenderTest < Test::Unit::TestCase
assert_match /\$37/, @response.body
end
+ def test_update_page_with_view_method
+ get :update_page_with_view_method
+ assert_template nil
+ assert_equal 'text/javascript; charset=utf-8', @response.headers['type']
+ assert_match /2 people/, @response.body
+ end
+
def test_yield_content_for
assert_not_deprecated { get :yield_content_for }
assert_equal "<title>Putting stuff in the title!</title>\n\nGreat stuff!\n", @response.body
@@ -1372,3 +1397,21 @@ class LastModifiedRenderTest < Test::Unit::TestCase
assert_equal @last_modified, @response.headers['Last-Modified']
end
end
+
+class RenderingLoggingTest < Test::Unit::TestCase
+ def setup
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ @controller = TestController.new
+
+ @request.host = "www.nextangle.com"
+ end
+
+ def test_logger_prints_layout_and_template_rendering_info
+ @controller.logger = MockLogger.new
+ get :layout_test
+ logged = @controller.logger.logged.find_all {|l| l =~ /render/i }
+ assert_equal "Rendering template within layouts/standard", logged[0]
+ assert_equal "Rendering test/hello_world", logged[1]
+ end
+end