aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-03-28 17:47:46 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-03-28 17:47:46 -0700
commitaea1477362b640ebe52cf991b915ad32e7bf2571 (patch)
treeae4005c56fba372099f51b2e1e7bd55bf541c44a /activerecord
parent25f94971abf71fe51089f53b72cc08b636c230b3 (diff)
downloadrails-aea1477362b640ebe52cf991b915ad32e7bf2571.tar.gz
rails-aea1477362b640ebe52cf991b915ad32e7bf2571.tar.bz2
rails-aea1477362b640ebe52cf991b915ad32e7bf2571.zip
make sure we have an active database connection before running each connection management test
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb6
-rw-r--r--activerecord/test/cases/connection_management_test.rb9
2 files changed, 10 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
index d88720c8bf..bcd3abc08d 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
@@ -116,7 +116,11 @@ module ActiveRecord
connection_handler.remove_connection(klass)
end
- delegate :clear_active_connections!, :clear_reloadable_connections!,
+ def clear_active_connections!
+ connection_handler.clear_active_connections!
+ end
+
+ delegate :clear_reloadable_connections!,
:clear_all_connections!,:verify_active_connections!, :to => :connection_handler
end
end
diff --git a/activerecord/test/cases/connection_management_test.rb b/activerecord/test/cases/connection_management_test.rb
index 82ea46b41f..1313e28bb1 100644
--- a/activerecord/test/cases/connection_management_test.rb
+++ b/activerecord/test/cases/connection_management_test.rb
@@ -20,8 +20,9 @@ module ActiveRecord
@app = App.new
@management = ConnectionManagement.new(@app)
- @connections_cleared = false
- ActiveRecord::Base.stubs(:clear_active_connections!).with { @connections_cleared = true }
+ # make sure we have an active connection
+ assert ActiveRecord::Base.connection
+ assert ActiveRecord::Base.connection_handler.active_connections?
end
def test_app_delegation
@@ -33,13 +34,13 @@ module ActiveRecord
test "clears active connections after each call" do
@management.call(@env)
- assert @connections_cleared
+ assert !ActiveRecord::Base.connection_handler.active_connections?
end
test "doesn't clear active connections when running in a test case" do
@env['rack.test'] = true
@management.call(@env)
- assert !@connections_cleared
+ assert ActiveRecord::Base.connection_handler.active_connections?
end
end
end