aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/inverse_associations_test.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-08-18 18:11:11 -0700
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-08-18 18:11:11 -0700
commitf9fc26e8007d5e2936cf5374a8168b2c37273490 (patch)
tree8d51ff8b59889e518b2c5a8450983af0b48ab068 /activerecord/test/cases/associations/inverse_associations_test.rb
parentaf26adcffbf97e8f7abdd63d0a4d501c70250a09 (diff)
parentc9c5566acef049f924ade61da2247a5c9456eba0 (diff)
downloadrails-f9fc26e8007d5e2936cf5374a8168b2c37273490.tar.gz
rails-f9fc26e8007d5e2936cf5374a8168b2c37273490.tar.bz2
rails-f9fc26e8007d5e2936cf5374a8168b2c37273490.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
Diffstat (limited to 'activerecord/test/cases/associations/inverse_associations_test.rb')
-rw-r--r--activerecord/test/cases/associations/inverse_associations_test.rb6
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