Patch database_cleaner to actually, you know, work.

This commit is contained in:
Sarah Mei 2010-12-28 22:23:27 -08:00
parent f18439fa14
commit 2184af09d9
2 changed files with 20 additions and 5 deletions

View file

@ -0,0 +1,16 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
DatabaseCleaner::ActiveRecord::Truncation.class_eval do
# You could argue that this technically isn't truncation. You'd be right.
# But something in the MySQL adapter segfaults (!) on actual truncation, and we
# don't have that much data in our tests, so a DELETE is not appreciably slower.
def clean
connection.disable_referential_integrity do
tables_to_truncate.each do |table_name|
connection.execute("DELETE FROM #{table_name};")
end
end
end
end

View file

@ -35,18 +35,17 @@ ActionController::Base.allow_rescue = false
require 'database_cleaner'
require 'database_cleaner/cucumber'
DatabaseCleaner.strategy = :transaction
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.orm = "active_record"
Cucumber::Rails::World.use_transactional_fixtures = true
Cucumber::Rails::World.use_transactional_fixtures = false
require File.join(File.dirname(__FILE__), "database_cleaner_patches")
require File.join(File.dirname(__FILE__), "..", "..", "spec", "helper_methods")
include HelperMethods
DatabaseCleaner.start
Before do
DatabaseCleaner.clean
DatabaseCleaner.start
end
module Resque