diff options
author | Angelo Capilleri <resca_air@MacBook-Air-di-angelo-giovanni-capilleri.local> | 2012-05-12 15:03:21 +0200 |
---|---|---|
committer | Angelo Capilleri <resca_air@MacBook-Air-di-angelo-giovanni-capilleri.local> | 2012-05-13 23:24:05 +0200 |
commit | f9ae1baa0ae47064d5100e48ffda1fe8b4fa34e7 (patch) | |
tree | 2c22b7a9ea42cf025b8c27793a9d1e70865f024d /activemodel/test | |
parent | 98355fe100d9e014e88ba9b1b78f606c9312bc44 (diff) | |
download | rails-f9ae1baa0ae47064d5100e48ffda1fe8b4fa34e7.tar.gz rails-f9ae1baa0ae47064d5100e48ffda1fe8b4fa34e7.tar.bz2 rails-f9ae1baa0ae47064d5100e48ffda1fe8b4fa34e7.zip |
clean the erros if an object that includes validations errors is duped. Fixes #5953
Diffstat (limited to 'activemodel/test')
-rw-r--r-- | activemodel/test/cases/validations_test.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb index a716d0896e..f9bb877316 100644 --- a/activemodel/test/cases/validations_test.rb +++ b/activemodel/test/cases/validations_test.rb @@ -344,4 +344,19 @@ class ValidationsTest < ActiveModel::TestCase Topic.validates :title, options assert_equal({ :presence => true }, options) 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 |