Merged updates from trunk into stable branch
[feedcatcher.git] / vendor / rails / activerecord / test / cases / connection_pool_test.rb
diff --git a/vendor/rails/activerecord/test/cases/connection_pool_test.rb b/vendor/rails/activerecord/test/cases/connection_pool_test.rb
new file mode 100644 (file)
index 0000000..cc9b2a4
--- /dev/null
@@ -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