Permalink
Browse files

Add regression test for setting inverse instances on normal & polymor…

…phic relationships when building objects on new records
  • Loading branch information...
fschwahn committed Apr 20, 2017
1 parent dc47c2b commit c2120582e4d27d2a64131820a46392af60f1e8b6
Showing with 14 additions and 0 deletions.
  1. +14 −0 activerecord/test/cases/associations/has_many_associations_test.rb
@@ -241,6 +241,13 @@ def test_create_from_association_with_nil_values_should_work
assert_equal "defaulty", bulb.name
end
def test_build_from_association_sets_inverse_instance
car = Car.new(name: "honda")
bulb = car.bulbs.build
assert_equal car, bulb.car
end
def test_do_not_call_callbacks_for_delete_all
car = Car.create(name: "honda")
car.funky_bulbs.create!
@@ -2146,6 +2153,13 @@ def test_build_with_polymorphic_has_many_does_not_allow_to_override_type_and_id
assert_equal "Post", tagging.taggable_type
end
def test_build_from_polymorphic_association_sets_inverse_instance
post = Post.new
tagging = post.taggings.build
assert_equal post, tagging.taggable
end
def test_dont_call_save_callbacks_twice_on_has_many
firm = companies(:first_firm)
contract = firm.contracts.create!

0 comments on commit c212058

Please sign in to comment.