aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations
diff options
context:
space:
mode:
authorArthur Neves <arthurnn@gmail.com>2013-10-04 11:15:55 -0400
committerArthur Neves <arthurnn@gmail.com>2013-10-04 11:15:55 -0400
commitfc59e997d7948f010aab6d888ab919198f1a20ac (patch)
tree403d9824048f6f9633596a8339a16f8660608454 /activerecord/test/cases/associations
parent655396cc100943c2b1afb6f172bc96b9e29c4aad (diff)
downloadrails-fc59e997d7948f010aab6d888ab919198f1a20ac.tar.gz
rails-fc59e997d7948f010aab6d888ab919198f1a20ac.tar.bz2
rails-fc59e997d7948f010aab6d888ab919198f1a20ac.zip
add regression test for set_inverse_instance on add_to_target
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r--activerecord/test/cases/associations/inverse_associations_test.rb13
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 51e466ecac..a44b78f200 100644
--- a/activerecord/test/cases/associations/inverse_associations_test.rb
+++ b/activerecord/test/cases/associations/inverse_associations_test.rb
@@ -290,6 +290,19 @@ 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_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