From 6bd8e351361a895e7ada7d7702bb099034103d62 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 26 Feb 2006 23:12:01 +0000 Subject: ActiveRecord::Base.remove_connection explicitly closes database connections and doesn't corrupt the connection cache. Introducing the disconnect! instance method for the PostgreSQL, MySQL, and SQL Server adapters; implementations for the others are welcome. References #3591. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3674 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/unconnected_test.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'activerecord/test/unconnected_test.rb') diff --git a/activerecord/test/unconnected_test.rb b/activerecord/test/unconnected_test.rb index df656ec773..2d06410dd8 100755 --- a/activerecord/test/unconnected_test.rb +++ b/activerecord/test/unconnected_test.rb @@ -7,19 +7,26 @@ class TestUnconnectedAdaptor < Test::Unit::TestCase self.use_transactional_fixtures = false def setup - @connection = ActiveRecord::Base.remove_connection + @underlying = ActiveRecord::Base.connection + @specification = ActiveRecord::Base.remove_connection end def teardown - ActiveRecord::Base.establish_connection(@connection) + @underlying = nil + ActiveRecord::Base.establish_connection(@specification) end - def test_unconnected + def test_connection_no_longer_established assert_raise(ActiveRecord::ConnectionNotEstablished) do - TestRecord.find(1) + TestRecord.find(1) end + assert_raise(ActiveRecord::ConnectionNotEstablished) do - TestRecord.new.save + TestRecord.new.save end end + + def test_underlying_adapter_no_longer_active + assert !@underlying.active?, "Removed adapter should no longer be active" + end end -- cgit v1.2.3