提交 5fe4e628 编写于 作者: K Kuldeep Aggarwal

`@destroyed` should always be set to `false` when an object is duped.

上级 98e8c96d
* `@destroyed` should always be set to `false` when an object is duped.
*Kuldeep Aggarwal*
* Fixed has_many association to make it support irregular inflections.
Fixes #8928.
......
......@@ -267,6 +267,7 @@ def initialize_dup(other) # :nodoc:
@attributes_cache = {}
@new_record = true
@destroyed = false
super
end
......
......@@ -233,6 +233,22 @@ def test_save_for_record_with_only_primary_key_that_is_provided
assert_nothing_raised { Minimalistic.create!(:id => 2) }
end
def test_save_with_duping_of_destroyed_object
developer = Developer.create(name: "Kuldeep")
developer.destroy
new_developer = developer.dup
new_developer.save
assert new_developer.persisted?
end
def test_dup_of_destroyed_object_is_not_destroyed
developer = Developer.create(name: "Kuldeep")
developer.destroy
new_developer = developer.dup
new_developer.save
assert_equal new_developer.destroyed?, false
end
def test_create_many
topics = Topic.create([ { "title" => "first" }, { "title" => "second" }])
assert_equal 2, topics.size
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册