We have a Ruby on Rails 2.3.8 project, where data are almost exclusively read only.
We would like to write acceptance tests which use staging database (copy of the production database)
So we do not want to use transactions or truncation of the database tables before or after features and scenarios.
Is it possible?
My solution was to switch DatabaseCleaner to transaction cleaning strategy in features/support/env.rb
if defined?(ActiveRecord::Base)
begin
require 'database_cleaner'
DatabaseCleaner.strategy = :transaction
rescue LoadError => ignore_if_database_cleaner_not_present
end
end
And monkey patch DatabaseCleaner by adding features/support/database_cleaner_patch.rb with
module DatabaseCleaner::ActiveRecord
#for now we will disable transactions
class Transaction
def start
end
def clean
end
end
end
We have 3 databases in our project, with cross-database queries so we cannot use transactions, otherwise I would not monkey patch DatabaseCleaner