aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2005-06-03 16:06:38 +0000
committerJamis Buck <jamis@37signals.com>2005-06-03 16:06:38 +0000
commitba254b5494b4cfae5a497ba6c748ea8c7121df1f (patch)
tree054b38001d83f53d80e95db29717be1bf7d0b7c6
parent6d9ee4a306672110c97b9dd9af77015208106654 (diff)
downloadrails-ba254b5494b4cfae5a497ba6c748ea8c7121df1f.tar.gz
rails-ba254b5494b4cfae5a497ba6c748ea8c7121df1f.tar.bz2
rails-ba254b5494b4cfae5a497ba6c748ea8c7121df1f.zip
Using transactional fixtures now causes the data to be loaded only once, for BIG speed improvements
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1384 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record/fixtures.rb10
2 files changed, 10 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index d44d966f5c..7a6f18986e 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Using transactional fixtures now causes the data to be loaded only once.
+
* Added fixture accessor methods that can be used when instantiated fixtures are disabled.
fixtures :web_sites
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 30b587b4ec..c32d3d78e4 100755
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -410,6 +410,8 @@ module Test #:nodoc:
self.use_instantiated_fixtures = true
self.pre_loaded_fixtures = false
+ @@already_loaded_fixtures = {}
+
def self.fixtures(*table_names)
table_names = table_names.flatten
self.fixture_table_names |= table_names
@@ -448,8 +450,12 @@ module Test #:nodoc:
# Load fixtures once and begin transaction.
if use_transactional_fixtures
- load_fixtures unless @already_loaded_fixtures
- @already_loaded_fixtures = true
+ if @@already_loaded_fixtures[self.class]
+ @loaded_fixtures = @@already_loaded_fixtures[self.class]
+ else
+ load_fixtures
+ @@already_loaded_fixtures[self.class] = @loaded_fixtures
+ end
ActiveRecord::Base.lock_mutex
ActiveRecord::Base.connection.begin_db_transaction