We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 47e6f19 commit 911570aCopy full SHA for 911570a
spec/support/shared_db_connection.rb
@@ -0,0 +1,25 @@
1
+class ActiveRecord::Base
2
+ mattr_accessor :shared_connection
3
+ @@shared_connection = nil
4
+
5
+ def self.connection
6
+ @@shared_connection || retrieve_connection
7
+ end
8
+end
9
10
+# Forces all threads to share the same connection. This works on
11
+# Capybara because it starts the web server in a thread.
12
+ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
13
14
+if Rails.env.javascript_test?
15
+ module ActiveRecord
16
+ module ConnectionAdapters
17
+ module QueryCache
18
+ private
19
+ def cache_sql(sql,binds)
20
+ yield
21
22
23
24
25
0 commit comments