2011-06-06 14:17:44 -04:00
|
|
|
require "cases/helper"
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
class TestRecord < ActiveRecord::Base
|
|
|
|
end
|
|
|
|
|
2008-01-21 12:20:51 -05:00
|
|
|
class TestUnconnectedAdapter < ActiveRecord::TestCase
|
2011-10-05 20:21:43 -04:00
|
|
|
self.use_transactional_fixtures = false
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
def setup
|
2011-12-28 13:07:08 -05:00
|
|
|
@underlying = ActiveRecord::Model.connection
|
|
|
|
@specification = ActiveRecord::Model.remove_connection
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
2006-02-26 18:12:01 -05:00
|
|
|
@underlying = nil
|
2011-12-28 13:07:08 -05:00
|
|
|
ActiveRecord::Model.establish_connection(@specification)
|
2011-01-08 13:33:33 -05:00
|
|
|
load_schema if in_memory_db?
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
2006-02-26 18:12:01 -05:00
|
|
|
def test_connection_no_longer_established
|
2004-11-23 20:04:44 -05:00
|
|
|
assert_raise(ActiveRecord::ConnectionNotEstablished) do
|
2006-02-26 18:12:01 -05:00
|
|
|
TestRecord.find(1)
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
2006-02-26 18:12:01 -05:00
|
|
|
|
2004-11-23 20:04:44 -05:00
|
|
|
assert_raise(ActiveRecord::ConnectionNotEstablished) do
|
2006-02-26 18:12:01 -05:00
|
|
|
TestRecord.new.save
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
end
|
2006-02-26 18:12:01 -05:00
|
|
|
|
|
|
|
def test_underlying_adapter_no_longer_active
|
|
|
|
assert !@underlying.active?, "Removed adapter should no longer be active"
|
|
|
|
end
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|