Skip to content
Browse files

add regression test for set_inverse_instance on add_to_target

  • Loading branch information...
1 parent 874ca68 commit 37cd223cb68f1ebb615bffc31bf69e93e6dbf382 @arthurnn arthurnn committed with rafaelfranca Oct 4, 2013
Showing with 13 additions and 0 deletions.
  1. +13 −0 activerecord/test/cases/associations/inverse_associations_test.rb
View
13 activerecord/test/cases/associations/inverse_associations_test.rb
@@ -446,6 +446,19 @@ def test_raise_record_not_found_error_when_no_ids_are_passed
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

0 comments on commit 37cd223

Please sign in to comment.
Something went wrong with that request. Please try again.