-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
3 changed files
with
35 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |