diff options
Diffstat (limited to 'activerecord/test/cases')
7 files changed, 14 insertions, 35 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb index f24109dcca..1b0c00bd5a 100644 --- a/activerecord/test/cases/associations/belongs_to_associations_test.rb +++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb @@ -227,23 +227,23 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase end assert r1.save - assert_equal 0, t1.reload.replies.size - assert_equal 1, t2.reload.replies.size + assert_equal 0, Topic.find(t1.id).replies.size + assert_equal 1, Topic.find(t2.id).replies.size r1.topic = nil - assert_equal 0, t1.reload.replies.size - assert_equal 0, t2.reload.replies.size + assert_equal 0, Topic.find(t1.id).replies.size + assert_equal 0, Topic.find(t2.id).replies.size r1.topic = t1 - assert_equal 1, t1.reload.replies.size - assert_equal 0, t2.reload.replies.size + assert_equal 1, Topic.find(t1.id).replies.size + assert_equal 0, Topic.find(t2.id).replies.size r1.destroy - assert_equal 0, t1.reload.replies.size - assert_equal 0, t2.reload.replies.size + assert_equal 0, Topic.find(t1.id).replies.size + assert_equal 0, Topic.find(t2.id).replies.size end def test_belongs_to_reassign_with_namespaced_models_and_counters @@ -259,8 +259,8 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase r1.topic = Web::Topic.find(t2.id) assert r1.save - assert_equal 0, t1.reload.replies.size - assert_equal 1, t2.reload.replies.size + assert_equal 0, Web::Topic.find(t1.id).replies.size + assert_equal 1, Web::Topic.find(t2.id).replies.size end def test_belongs_to_counter_after_save diff --git a/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb b/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb index fae4029bbc..fb59f63f91 100644 --- a/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb +++ b/activerecord/test/cases/associations/eager_load_includes_full_sti_class_test.rb @@ -27,8 +27,6 @@ class EagerLoadIncludeFullStiClassNamesTest < ActiveRecord::TestCase post = Namespaced::Post.find_by_title( 'Great stuff', :include => :tagging ) assert_nil post.tagging - ActiveRecord::IdentityMap.clear # we need to clear IM to reload post. - ActiveRecord::Base.store_full_sti_class = true post = Namespaced::Post.find_by_title( 'Great stuff', :include => :tagging ) assert_instance_of Tagging, post.tagging diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index 1782309b3e..c00b8a1cde 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -170,7 +170,6 @@ class EagerAssociationTest < ActiveRecord::TestCase author = authors(:david) post = author.post_about_thinking_with_last_comment last_comment = post.last_comment - ActiveRecord::IdentityMap.clear # We need to clear cache to force reload in next block author = assert_queries(3) { Author.find(author.id, :include => {:post_about_thinking_with_last_comment => :last_comment})} # find the author, then find the posts, then find the comments assert_no_queries do assert_equal post, author.post_about_thinking_with_last_comment @@ -182,7 +181,6 @@ class EagerAssociationTest < ActiveRecord::TestCase post = posts(:welcome) author = post.author author_address = author.author_address - ActiveRecord::IdentityMap.clear # We need to clear cache to force reload in next block post = assert_queries(3) { Post.find(post.id, :include => {:author_with_address => :author_address}) } # find the post, then find the author, then find the address assert_no_queries do assert_equal author, post.author_with_address @@ -785,7 +783,6 @@ class EagerAssociationTest < ActiveRecord::TestCase end def test_eager_loading_with_conditions_on_joined_table_preloads - ActiveRecord::IdentityMap.without do # IM caches records, so we need to disable it to test this functionality. posts = assert_queries(2) do Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id') end @@ -807,11 +804,10 @@ class EagerAssociationTest < ActiveRecord::TestCase Post.find(:all, :include => :author, :joins => {:taggings => {:tag => :taggings}}, :conditions => "taggings_tags.super_tag_id=2", :order => 'posts.id') end assert_equal posts(:welcome, :thinking), posts - end + end def test_eager_loading_with_conditions_on_string_joined_table_preloads - ActiveRecord::IdentityMap.without do # IM caches records, so we need to disable it to test this functionality. posts = assert_queries(2) do Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => "INNER JOIN comments on comments.post_id = posts.id", :conditions => "comments.body like 'Thank you%'", :order => 'posts.id') end @@ -823,7 +819,7 @@ class EagerAssociationTest < ActiveRecord::TestCase end assert_equal [posts(:welcome)], posts assert_equal authors(:david), assert_no_queries { posts[0].author} - end + end def test_eager_loading_with_select_on_joined_table_preloads diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb index 59fc13fe51..b13cb2d7a2 100644 --- a/activerecord/test/cases/autosave_association_test.rb +++ b/activerecord/test/cases/autosave_association_test.rb @@ -578,7 +578,7 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase @pirate.ship.mark_for_destruction assert !@pirate.reload.marked_for_destruction? - assert !@pirate.ship.target.reload.marked_for_destruction? + assert !@pirate.ship.marked_for_destruction? end # has_one @@ -1194,7 +1194,6 @@ class TestAutosaveAssociationValidationsOnAHasOneAssociation < ActiveRecord::Tes self.use_transactional_fixtures = false def setup - ActiveRecord::IdentityMap.enabled = false # This tests use trick with double association, IM prevents that, so we disable it. @pirate = Pirate.create(:catchphrase => "Don' botharrr talkin' like one, savvy?") @pirate.create_ship(:name => 'titanic') end @@ -1210,10 +1209,6 @@ class TestAutosaveAssociationValidationsOnAHasOneAssociation < ActiveRecord::Tes @pirate.non_validated_ship.name = '' assert @pirate.valid? end - - def teardown - ActiveRecord::IdentityMap.enabled = true - end end class TestAutosaveAssociationValidationsOnABelongsToAssociation < ActiveRecord::TestCase diff --git a/activerecord/test/cases/identity_map_test.rb b/activerecord/test/cases/identity_map_test.rb index df77bc5af2..7086af614f 100644 --- a/activerecord/test/cases/identity_map_test.rb +++ b/activerecord/test/cases/identity_map_test.rb @@ -292,6 +292,7 @@ class IdentityMapTest < ActiveRecord::TestCase assert_equal [posts(:welcome)], posts assert_equal authors(:david), assert_no_queries { posts[0].author} end +<<<<<<< HEAD ############################################################################## # Behaviour releated to saving failures diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb index 20a24c38fa..92af53d56f 100644 --- a/activerecord/test/cases/nested_attributes_test.rb +++ b/activerecord/test/cases/nested_attributes_test.rb @@ -551,7 +551,6 @@ module NestedAttributesOnACollectionAssociationTests assert_equal 'Grace OMalley', @child_1.reload.name end - def test_should_not_overwrite_unsaved_updates_when_loading_association @pirate.reload @pirate.send(association_setter, [{ :id => @child_1.id, :name => 'Grace OMalley' }]) diff --git a/activerecord/test/cases/readonly_test.rb b/activerecord/test/cases/readonly_test.rb index 448c8f8796..98011f40a4 100644 --- a/activerecord/test/cases/readonly_test.rb +++ b/activerecord/test/cases/readonly_test.rb @@ -40,10 +40,6 @@ class ReadOnlyTest < ActiveRecord::TestCase def test_find_with_joins_option_implies_readonly - # We disable IM, becouse we want to check default settings here - # adding readonly(false) does not update readonly status with IM - # (see corresponding test in IM) - ActiveRecord::IdentityMap.without do # Blank joins don't count. Developer.joins(' ').each { |d| assert !d.readonly? } Developer.joins(' ').readonly(false).each { |d| assert !d.readonly? } @@ -51,7 +47,6 @@ class ReadOnlyTest < ActiveRecord::TestCase # Others do. Developer.joins(', projects').each { |d| assert d.readonly? } Developer.joins(', projects').readonly(false).each { |d| assert !d.readonly? } - end end @@ -77,10 +72,6 @@ class ReadOnlyTest < ActiveRecord::TestCase end def test_readonly_scoping - # We disable IM, becouse we want to check default settings here - # adding readonly(false) does not update readonly status with IM - # (see corresponding test in IM) - ActiveRecord::IdentityMap.without do Post.send(:with_scope, :find => { :conditions => '1=1' }) do assert !Post.find(1).readonly? assert Post.readonly(true).find(1).readonly? @@ -108,7 +99,6 @@ class ReadOnlyTest < ActiveRecord::TestCase assert Post.readonly.find(1).readonly? assert !Post.readonly(false).find(1).readonly? end - end end def test_association_collection_method_missing_scoping_not_readonly |