Permalink
Browse files

Don't change tests, fix code: if locking is enabled skip IM.

  • Loading branch information...
1 parent 5ee3663 commit 7892543a88e5ec2329e3834a591a7b3b80d165f0 @miloops miloops committed Oct 20, 2010
Showing with 1 addition and 14 deletions.
  1. +1 −1 activerecord/lib/active_record/relation.rb
  2. +0 −13 activerecord/test/cases/locking_test.rb
@@ -61,7 +61,7 @@ def respond_to?(method, include_private = false)
def to_a
return @records if loaded?
- @records = if @readonly_value.nil?
+ @records = if @readonly_value.nil? && !@klass.locking_enabled?
eager_loading? ? find_with_associations : @klass.find_by_sql(arel.to_sql, @bind_values)
else
IdentityMap.without do
@@ -15,11 +15,6 @@ 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
@@ -28,10 +23,6 @@ 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)
@@ -224,10 +215,6 @@ def test_update_without_attributes_does_not_only_update_lock_version
end
end
- def teardown
- ActiveRecord::IdentityMap.enabled = true
- end
-
private
def add_counter_column_to(model, col='test_count')

0 comments on commit 7892543

Please sign in to comment.