Patch database_cleaner to actually, you know, work.
This commit is contained in:
parent
f18439fa14
commit
2184af09d9
2 changed files with 20 additions and 5 deletions
16
features/support/database_cleaner_patches.rb
Normal file
16
features/support/database_cleaner_patches.rb
Normal 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
|
||||||
|
|
@ -35,18 +35,17 @@ ActionController::Base.allow_rescue = false
|
||||||
|
|
||||||
require 'database_cleaner'
|
require 'database_cleaner'
|
||||||
require 'database_cleaner/cucumber'
|
require 'database_cleaner/cucumber'
|
||||||
DatabaseCleaner.strategy = :transaction
|
DatabaseCleaner.strategy = :truncation
|
||||||
DatabaseCleaner.orm = "active_record"
|
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")
|
require File.join(File.dirname(__FILE__), "..", "..", "spec", "helper_methods")
|
||||||
include HelperMethods
|
include HelperMethods
|
||||||
|
|
||||||
DatabaseCleaner.start
|
|
||||||
|
|
||||||
Before do
|
Before do
|
||||||
DatabaseCleaner.clean
|
DatabaseCleaner.clean
|
||||||
DatabaseCleaner.start
|
|
||||||
end
|
end
|
||||||
|
|
||||||
module Resque
|
module Resque
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue