From 16e80a50acbd68779cbf063f0526e05ce6ba21ad Mon Sep 17 00:00:00 2001 From: Ryan Wallace Date: Thu, 7 Apr 2011 11:58:05 -0700 Subject: [PATCH] Add failing test for test_parent_instance_should_be_shared_with_children_who_eager_load_an_association. --- .../associations/inverse_associations_test.rb | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb index 7628221..b69439b 100644 --- a/activerecord/test/cases/associations/inverse_associations_test.rb +++ b/activerecord/test/cases/associations/inverse_associations_test.rb @@ -262,6 +262,18 @@ class InverseHasManyTests < ActiveRecord::TestCase def test_trying_to_use_inverses_that_dont_exist_should_raise_an_error assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Man.find(:first).secret_interests } end + + def test_parent_instance_should_be_shared_with_children_who_eager_load_an_association + m = men(:gordon) + is = m.interests.includes(:zine) + is.each do |i| + assert_equal m.name, i.man.name, "Name of man should be the same before changes to parent instance" + m.name = 'Bongo' + assert_equal m.name, i.man.name, "Name of man should be the same after changes to parent instance" + i.man.name = 'Mungo' + assert_equal m.name, i.man.name, "Name of man should be the same after changes to child-owned instance" + end + end end class InverseBelongsToTests < ActiveRecord::TestCase -- 1.7.0.2