Permalink
Browse files

Merge pull request #14796 from kuldeepaggarwal/fix-save-issue

when a destroyed record is duped, it is no longer ´destroyed?`.
  • Loading branch information...
1 parent 88d8f6e commit d63c39fbfe19def54b25706105802f3fa7e09e52 @senny senny committed Apr 18, 2014
@@ -1,3 +1,7 @@
+* When a destroyed record is duped, the dup is not `destroyed?`.
+
+ *Kuldeep Aggarwal*
+
* Fixed has_many association to make it support irregular inflections.
Fixes #8928.
@@ -257,6 +257,7 @@ def initialize_dup(other) # :nodoc:
@attributes_cache = {}
@new_record = true
+ @destroyed = false
ensure_proper_type
super
@@ -206,6 +206,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

0 comments on commit d63c39f

Please sign in to comment.