aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/locking_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases/locking_test.rb')
-rw-r--r--activerecord/test/cases/locking_test.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb
index 4ddcdc010b..5ceb19e7c8 100644
--- a/activerecord/test/cases/locking_test.rb
+++ b/activerecord/test/cases/locking_test.rb
@@ -15,6 +15,11 @@ class ReadonlyFirstNamePerson < Person
attr_readonly :first_name
end
+# Becouse of introduction of IdentityMap optimistic locking should only be needed
+# in multithreaded applications, or when more then one software operates on database.
+#
+# I'm using ActiveRecord::IdentityMap.without to prevent Identity map from
+# using one record here.
class OptimisticLockingTest < ActiveRecord::TestCase
fixtures :people, :legacy_things, :references
@@ -23,6 +28,10 @@ class OptimisticLockingTest < ActiveRecord::TestCase
# of a test (see test_increment_counter_*).
self.use_transactional_fixtures = false
+ def setup
+ ActiveRecord::IdentityMap.enabled = false
+ end
+
def test_lock_existing
p1 = Person.find(1)
p2 = Person.find(1)
@@ -215,6 +224,10 @@ class OptimisticLockingTest < ActiveRecord::TestCase
end
end
+ def teardown
+ ActiveRecord::IdentityMap.enabled = true
+ end
+
private
def add_counter_column_to(model, col='test_count')