aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/dup_test.rb
diff options
context:
space:
mode:
authorChristian Seiler <chr.seiler@gmail.com>2012-08-16 23:19:47 +0200
committerChristian Seiler <chr.seiler@gmail.com>2012-10-16 15:09:23 +0200
commitfb665217723f7c4e9e96bb7658fc3048a1d64379 (patch)
treeb4fd3448e9f2100a88c183ba26e65284fd098944 /activerecord/test/cases/dup_test.rb
parentda1aa759b0004e058a60229bb6cbf3363887d498 (diff)
downloadrails-fb665217723f7c4e9e96bb7658fc3048a1d64379.tar.gz
rails-fb665217723f7c4e9e96bb7658fc3048a1d64379.tar.bz2
rails-fb665217723f7c4e9e96bb7658fc3048a1d64379.zip
Call super to nullify the reference to the original errors object in the dup'ed object (call ActiveModel::Validations#initialize_dup). Closes #7291
Diffstat (limited to 'activerecord/test/cases/dup_test.rb')
-rw-r--r--activerecord/test/cases/dup_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/dup_test.rb b/activerecord/test/cases/dup_test.rb
index 71b2b16608..4e2adff344 100644
--- a/activerecord/test/cases/dup_test.rb
+++ b/activerecord/test/cases/dup_test.rb
@@ -107,5 +107,19 @@ module ActiveRecord
assert Topic.after_initialize_called
end
+ def test_dup_validity_is_independent
+ Topic.validates_presence_of :title
+ topic = Topic.new("title" => "Litterature")
+ topic.valid?
+
+ duped = topic.dup
+ duped.title = nil
+ assert duped.invalid?
+
+ topic.title = nil
+ duped.title = 'Mathematics'
+ assert topic.invalid?
+ assert duped.valid?
+ end
end
end