2008-01-21 12:20:51 -05: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
|
2005-06-10 10:58:02 -04:00
|
|
|
self.use_transactional_fixtures = false
|
2004-11-23 20:04:44 -05:00
|
|
|
|
|
|
|
def setup
|
2006-02-26 18:12:01 -05:00
|
|
|
@underlying = ActiveRecord::Base.connection
|
|
|
|
@specification = ActiveRecord::Base.remove_connection
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
2006-02-26 18:12:01 -05:00
|
|
|
@underlying = nil
|
|
|
|
ActiveRecord::Base.establish_connection(@specification)
|
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
|