aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/support
diff options
context:
space:
mode:
authorGuo Xiang Tan <tgx_world@hotmail.com>2014-04-01 22:04:10 -0700
committerGuo Xiang Tan <tgx_world@hotmail.com>2014-04-03 01:06:43 -0700
commitf1169d9d2509189a16f7b03fee5c76b9d023a347 (patch)
treeccab4bb3499174accf6af54ee68ac7ff654415f3 /activerecord/test/support
parent79f06a91345a301e1a2f2378552b5860a493b256 (diff)
downloadrails-f1169d9d2509189a16f7b03fee5c76b9d023a347.tar.gz
rails-f1169d9d2509189a16f7b03fee5c76b9d023a347.tar.bz2
rails-f1169d9d2509189a16f7b03fee5c76b9d023a347.zip
Add ConnectionHelper to refactor tests.
Diffstat (limited to 'activerecord/test/support')
-rw-r--r--activerecord/test/support/connection_helper.rb14
-rw-r--r--activerecord/test/support/postgresql_helper.rb8
2 files changed, 14 insertions, 8 deletions
diff --git a/activerecord/test/support/connection_helper.rb b/activerecord/test/support/connection_helper.rb
new file mode 100644
index 0000000000..4a19e5df44
--- /dev/null
+++ b/activerecord/test/support/connection_helper.rb
@@ -0,0 +1,14 @@
+module ConnectionHelper
+ def run_without_connection
+ original_connection = ActiveRecord::Base.remove_connection
+ yield original_connection
+ ensure
+ ActiveRecord::Base.establish_connection(original_connection)
+ end
+
+ # Used to drop all cache query plans in tests.
+ def reset_connection
+ original_connection = ActiveRecord::Base.remove_connection
+ ActiveRecord::Base.establish_connection(original_connection)
+ end
+end
diff --git a/activerecord/test/support/postgresql_helper.rb b/activerecord/test/support/postgresql_helper.rb
deleted file mode 100644
index fa40a46499..0000000000
--- a/activerecord/test/support/postgresql_helper.rb
+++ /dev/null
@@ -1,8 +0,0 @@
-module PostgresqlHelper
- # Make sure to drop all cached query plans to prevent invalid reference errors like:
- # cache lookup failed for type XYZ
- def reset_pg_session
- original_connection = ActiveRecord::Base.remove_connection
- ActiveRecord::Base.establish_connection(original_connection)
- end
-end