Skip to content

Instantly share code, notes, and snippets.

@tak1n
Created June 25, 2014 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tak1n/f224058fa92f9f4840a3 to your computer and use it in GitHub Desktop.
Save tak1n/f224058fa92f9f4840a3 to your computer and use it in GitHub Desktop.
When testing with capybara
# Make all database transactions use the same thread
# This is needed so tests wich uses webkit (javascript enabled feature testing) also use the same thread for database transactions
# Furthermore this is needed so db changes made in these feature tests are able to be rolled back
ActiveRecord::ConnectionAdapters::ConnectionPool.class_eval do
def current_connection_id
Thread.main.object_id
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment