2013-06-12 08:15:15 -04:00
|
|
|
require "cases/helper"
|
|
|
|
|
|
|
|
class TestRecord < ActiveRecord::Base
|
|
|
|
end
|
|
|
|
|
|
|
|
class TestDisconnectedAdapter < ActiveRecord::TestCase
|
|
|
|
self.use_transactional_fixtures = false
|
|
|
|
|
|
|
|
def setup
|
|
|
|
@connection = ActiveRecord::Base.connection
|
|
|
|
end
|
|
|
|
|
2014-03-14 00:35:58 -04:00
|
|
|
teardown do
|
2013-06-28 06:37:42 -04:00
|
|
|
return if in_memory_db?
|
2013-06-12 08:15:15 -04:00
|
|
|
spec = ActiveRecord::Base.connection_config
|
|
|
|
ActiveRecord::Base.establish_connection(spec)
|
|
|
|
end
|
|
|
|
|
2013-11-08 10:57:51 -05:00
|
|
|
unless in_memory_db?
|
|
|
|
test "can't execute statements while disconnected" do
|
2013-06-12 08:15:15 -04:00
|
|
|
@connection.execute "SELECT count(*) from products"
|
2013-11-08 10:57:51 -05:00
|
|
|
@connection.disconnect!
|
|
|
|
assert_raises(ActiveRecord::StatementInvalid) do
|
|
|
|
@connection.execute "SELECT count(*) from products"
|
|
|
|
end
|
2013-06-12 08:15:15 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|