diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-04-03 10:48:27 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-04-03 10:48:27 +0200 |
commit | 7531404a4401eb649daf274430c79ad7db6aaf9d (patch) | |
tree | 0d2888d4879f747d3667deadce19fd3676ce3d46 /activerecord/test/cases/adapters/mysql | |
parent | bd34a950dc7e21abe1340f630082c86197ad9dfc (diff) | |
parent | f1169d9d2509189a16f7b03fee5c76b9d023a347 (diff) | |
download | rails-7531404a4401eb649daf274430c79ad7db6aaf9d.tar.gz rails-7531404a4401eb649daf274430c79ad7db6aaf9d.tar.bz2 rails-7531404a4401eb649daf274430c79ad7db6aaf9d.zip |
Merge pull request #14561 from tgxworld/refactor_run_without_connection
Add ConnectionHelper to refactor tests.
Diffstat (limited to 'activerecord/test/cases/adapters/mysql')
-rw-r--r-- | activerecord/test/cases/adapters/mysql/active_schema_test.rb | 9 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/mysql/connection_test.rb | 11 |
2 files changed, 6 insertions, 14 deletions
diff --git a/activerecord/test/cases/adapters/mysql/active_schema_test.rb b/activerecord/test/cases/adapters/mysql/active_schema_test.rb index d1c644c016..7c0f11b033 100644 --- a/activerecord/test/cases/adapters/mysql/active_schema_test.rb +++ b/activerecord/test/cases/adapters/mysql/active_schema_test.rb @@ -1,10 +1,10 @@ require "cases/helper" +require 'support/connection_helper' class ActiveSchemaTest < ActiveRecord::TestCase - def setup - @connection = ActiveRecord::Base.remove_connection - ActiveRecord::Base.establish_connection(@connection) + include ConnectionHelper + def setup ActiveRecord::Base.connection.singleton_class.class_eval do alias_method :execute_without_stub, :execute def execute(sql, name = nil) return sql end @@ -12,8 +12,7 @@ class ActiveSchemaTest < ActiveRecord::TestCase end teardown do - ActiveRecord::Base.remove_connection - ActiveRecord::Base.establish_connection(@connection) + reset_connection end def test_add_index diff --git a/activerecord/test/cases/adapters/mysql/connection_test.rb b/activerecord/test/cases/adapters/mysql/connection_test.rb index 42ffb91095..412efa22ff 100644 --- a/activerecord/test/cases/adapters/mysql/connection_test.rb +++ b/activerecord/test/cases/adapters/mysql/connection_test.rb @@ -1,7 +1,9 @@ require "cases/helper" +require 'support/connection_helper' require 'support/ddl_helper' class MysqlConnectionTest < ActiveRecord::TestCase + include ConnectionHelper include DdlHelper class Klass < ActiveRecord::Base @@ -160,15 +162,6 @@ class MysqlConnectionTest < ActiveRecord::TestCase private - def run_without_connection - original_connection = ActiveRecord::Base.remove_connection - begin - yield original_connection - ensure - ActiveRecord::Base.establish_connection(original_connection) - end - end - def with_example_table(&block) definition ||= <<-SQL `id` int(11) auto_increment PRIMARY KEY, |