提交 c2120582 编写于 作者: F Fabian Schwahn

Add regression test for setting inverse instances on normal & polymorphic...

Add regression test for setting inverse instances on normal & polymorphic relationships when building objects on new records
上级 dc47c2be
......@@ -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!
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册