diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-06-12 14:15:15 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-06-15 14:35:14 +0200 |
commit | 36bc4f5a02f34c68d0e640ab84eb086a54cbd6ab (patch) | |
tree | b61fc06f2d30abc9abd1e2b1cf55a42a755ca548 /activerecord/test | |
parent | 7078ec3f9899e9841d4425cda6908d2b72c246a1 (diff) | |
download | rails-36bc4f5a02f34c68d0e640ab84eb086a54cbd6ab.tar.gz rails-36bc4f5a02f34c68d0e640ab84eb086a54cbd6ab.tar.bz2 rails-36bc4f5a02f34c68d0e640ab84eb086a54cbd6ab.zip |
regression test + mysql2 adapter raises correct error if conn is closed.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/disconnected_test.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/activerecord/test/cases/disconnected_test.rb b/activerecord/test/cases/disconnected_test.rb new file mode 100644 index 0000000000..cc2c1f6489 --- /dev/null +++ b/activerecord/test/cases/disconnected_test.rb @@ -0,0 +1,26 @@ +require "cases/helper" + +class TestRecord < ActiveRecord::Base +end + +class TestDisconnectedAdapter < ActiveRecord::TestCase + self.use_transactional_fixtures = false + + def setup + @connection = ActiveRecord::Base.connection + end + + def teardown + spec = ActiveRecord::Base.connection_config + ActiveRecord::Base.establish_connection(spec) + @connection = nil + end + + test "can't execute statements while disconnected" do + @connection.execute "SELECT count(*) from products" + @connection.disconnect! + assert_raises(ActiveRecord::StatementInvalid) do + @connection.execute "SELECT count(*) from products" + end + end +end |