diff --git a/features/support/database_cleaner_patches.rb b/features/support/database_cleaner_patches.rb new file mode 100644 index 000000000..804329dc0 --- /dev/null +++ b/features/support/database_cleaner_patches.rb @@ -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 \ No newline at end of file diff --git a/features/support/env.rb b/features/support/env.rb index ffb1c2189..416f06b57 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -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