diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-05-15 05:20:57 -0700 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-05-15 05:20:57 -0700 |
commit | 3d1b078a5b23d03fa827779767a0f97aa3ccac4b (patch) | |
tree | 85e3a44b5c5f19ecc243da73242fe3ce183fd186 /activemodel/test | |
parent | dd42e8905830f96db29d49ed4bd44eeca5195de3 (diff) | |
parent | f9ae1baa0ae47064d5100e48ffda1fe8b4fa34e7 (diff) | |
download | rails-3d1b078a5b23d03fa827779767a0f97aa3ccac4b.tar.gz rails-3d1b078a5b23d03fa827779767a0f97aa3ccac4b.tar.bz2 rails-3d1b078a5b23d03fa827779767a0f97aa3ccac4b.zip |
Merge pull request #6284 from acapilleri/dup_validation
clean the erros if an object that includes validation is duped.
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 |