diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-08-18 18:11:11 -0700 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-08-21 01:00:14 -0300 |
commit | fdf4eae506fa9895e831f569bed3c4aa6a999a22 (patch) | |
tree | 64f459809fd696218e6010d778324cbba7f7ee82 /activerecord/test | |
parent | b3bea4993896d9fb524a7c1f848fff6811e35297 (diff) | |
download | rails-fdf4eae506fa9895e831f569bed3c4aa6a999a22.tar.gz rails-fdf4eae506fa9895e831f569bed3c4aa6a999a22.tar.bz2 rails-fdf4eae506fa9895e831f569bed3c4aa6a999a22.zip |
Merge pull request #7377 from brainopia/use_inversed_parent_for_first_and_last_child
Use inversed parent for first and last child of has_many association
[Backport] Closes #3223.
Conflicts:
activerecord/lib/active_record/associations/collection_association.rb
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 76282213d8..e03d7916f1 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.find(:first).secret_interests } end |