diff options
author | brainopia <brainopia@evilmartians.com> | 2012-08-17 17:50:12 +0400 |
---|---|---|
committer | brainopia <brainopia@evilmartians.com> | 2012-08-18 18:11:28 +0400 |
commit | c9c5566acef049f924ade61da2247a5c9456eba0 (patch) | |
tree | ce900e697da966f27aa2a43a12730554cab5f556 /activerecord/test | |
parent | 9f8852128f2ad968e15b53728bb5c9fb3ba52e3b (diff) | |
download | rails-c9c5566acef049f924ade61da2247a5c9456eba0.tar.gz rails-c9c5566acef049f924ade61da2247a5c9456eba0.tar.bz2 rails-c9c5566acef049f924ade61da2247a5c9456eba0.zip |
Use inversed parent for first and last child of has_many association
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/inverse_associations_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/inverse_associations_test.rb b/activerecord/test/cases/associations/inverse_associations_test.rb index 8cb8a5a861..aad48e7ce9 100644 --- a/activerecord/test/cases/associations/inverse_associations_test.rb +++ b/activerecord/test/cases/associations/inverse_associations_test.rb @@ -259,6 +259,12 @@ class InverseHasManyTests < ActiveRecord::TestCase assert_equal m.name, i.man.name, "Name of man should be the same after changes to replaced-child-owned instance" end + def test_parent_instance_should_be_shared_with_first_and_last_child + man = Man.first + assert man.interests.first.man.equal? man + assert man.interests.last.man.equal? man + end + def test_trying_to_use_inverses_that_dont_exist_should_raise_an_error assert_raise(ActiveRecord::InverseOfAssociationNotFoundError) { Man.first.secret_interests } end |