Skip to content

Commit

Permalink
Replace database cleaner setting from :transaction to :truncation
Browse files Browse the repository at this point in the history
This patch removes the codes for the shared connection for tranction.
  • Loading branch information
kaznum committed Sep 15, 2014
1 parent 88c6d1f commit cbfa50d
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
# Remove/comment out the lines below if your app doesn't have a database.
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
begin
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.strategy = :truncation
rescue NameError
raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
end
Expand All @@ -99,32 +99,13 @@

Capybara.javascript_driver = :webkit

# codes for for transactional fixtures
# TODO
# see https://github.com/brianmario/mysql2/issues/99
# and https://gist.github.com/mperham/3049152
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil

def self.connection
@@shared_connection || ::ConnectionPool::Wrapper.new(:size => 1) { retrieve_connection }
end
end

# Forces all threads to share the same connection. This works on
# Capybara because it starts the web server in a thread.
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection

Before do
ActiveRecord::FixtureSet::reset_cache
fixtures_folder = File.join(Rails.root, 'spec', 'fixtures')
fixtures = Dir[File.join(fixtures_folder, '*.yml')].map {|f| File.basename(f, '.yml') }
ActiveRecord::FixtureSet::create_fixtures(fixtures_folder, fixtures)
end

## end of codes for transactional fixtures

if ENV['TRAVIS']
Capybara.default_wait_time = 60
else
Expand Down

0 comments on commit cbfa50d

Please sign in to comment.