提交 c141dfc8 编写于 作者: J Jeremy Kemper

Add a failing test for assigning nil to a polymorphic belongs_to not nullifying its _type column

上级 b6415428
......@@ -578,6 +578,19 @@ def test_polymorphic_assignment_with_primary_key_updates_foreign_id_field_for_ne
assert_nil essay.writer_id
end
def test_polymorphic_assignment_with_nil
essay = Essay.new
assert_nil essay.writer_id
assert_nil essay.writer_type
essay.writer_id = 1
essay.writer_type = 'Author'
essay.writer = nil
assert_nil essay.writer_id
assert_nil essay.writer_type
end
def test_belongs_to_proxy_should_not_respond_to_private_methods
assert_raise(NoMethodError) { companies(:first_firm).private_method }
assert_raise(NoMethodError) { companies(:second_client).firm.private_method }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册