aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorManfred Stienstra <manfred@fngtps.com>2009-02-25 10:29:22 +0100
committerJoshua Peek <josh@joshpeek.com>2009-02-25 12:48:53 -0600
commit809409d92fa57555fe0b3a148e41d2a47a1551d2 (patch)
tree660bfcda542cd155d9ca5df854867ade2e7cae6f /activerecord
parent0a8c003b1e0459b5bcfa47f49cc74f7a6b3851f8 (diff)
downloadrails-809409d92fa57555fe0b3a148e41d2a47a1551d2.tar.gz
rails-809409d92fa57555fe0b3a148e41d2a47a1551d2.tar.bz2
rails-809409d92fa57555fe0b3a148e41d2a47a1551d2.zip
Add test case for ActiveRecord::ConnectionAdapters::ConnectionManagement.
- Make sure ConnectionManagement clears connections after each call, except in tests Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/connection_pool_test.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/activerecord/test/cases/connection_pool_test.rb b/activerecord/test/cases/connection_pool_test.rb
new file mode 100644
index 0000000000..cc9b2a45f4
--- /dev/null
+++ b/activerecord/test/cases/connection_pool_test.rb
@@ -0,0 +1,25 @@
+require "cases/helper"
+
+class ConnectionManagementTest < ActiveRecord::TestCase
+ def setup
+ @env = {}
+ @app = stub('App')
+ @management = ActiveRecord::ConnectionAdapters::ConnectionManagement.new(@app)
+
+ @connections_cleared = false
+ ActiveRecord::Base.stubs(:clear_active_connections!).with { @connections_cleared = true }
+ end
+
+ test "clears active connections after each call" do
+ @app.expects(:call).with(@env)
+ @management.call(@env)
+ assert @connections_cleared
+ end
+
+ test "doesn't clear active connections when running in a test case" do
+ @env['rack.test'] = true
+ @app.expects(:call).with(@env)
+ @management.call(@env)
+ assert !@connections_cleared
+ end
+end \ No newline at end of file