diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-06-15 14:51:17 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-06-15 14:51:17 +0200 |
commit | a51d4e6c25d1e76327665db0c897094a5308d4ef (patch) | |
tree | 027c2440c168dfad43bb3ca58726c3fc473b0dce /activerecord/test/cases/disconnected_test.rb | |
parent | f42e0fd3f4d3e2f4b806b001b6ed88c8da8cd833 (diff) | |
download | rails-a51d4e6c25d1e76327665db0c897094a5308d4ef.tar.gz rails-a51d4e6c25d1e76327665db0c897094a5308d4ef.tar.bz2 rails-a51d4e6c25d1e76327665db0c897094a5308d4ef.zip |
Merge pull request #10925 from senny/10917_test_to_prevent_regression
regression test + mysql2 adapter raises correct error if conn is closed.
Conflicts:
activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/test/cases/disconnected_test.rb')
-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 |