diff options
author | Arthur Neves <arthurnn@gmail.com> | 2013-10-04 11:15:55 -0400 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-10-04 14:01:45 -0300 |
commit | 37cd223cb68f1ebb615bffc31bf69e93e6dbf382 (patch) | |
tree | 62abaabf4c27be470e3ff18bfbec783aaf5d4b80 /activerecord/test | |
parent | 874ca68f3d3a8e1b538edc95e332654a79057c21 (diff) | |
download | rails-37cd223cb68f1ebb615bffc31bf69e93e6dbf382.tar.gz rails-37cd223cb68f1ebb615bffc31bf69e93e6dbf382.tar.bz2 rails-37cd223cb68f1ebb615bffc31bf69e93e6dbf382.zip |
add regression test for set_inverse_instance on add_to_target
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/inverse_associations_test.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb index 2477e60e51..8c81e00865 100644 --- a/activerecord/test/cases/associations/inverse_associations_test.rb +++ b/activerecord/test/cases/associations/inverse_associations_test.rb @@ -446,6 +446,19 @@ class InverseHasManyTests < ActiveRecord::TestCase def test_trying_to_use_inverses_that_dont_exist_should_raise_an_error assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Man.first.secret_interests } end + + def test_child_instance_should_point_to_parent_without_saving + man = Man.new + i = Interest.create(:topic => 'Industrial Revolution Re-enactment') + + man.interests << i + assert_not_nil i.man + + i.man.name = "Charles" + assert_equal i.man.name, man.name + + assert !man.persisted? + end end class InverseBelongsToTests < ActiveRecord::TestCase |