From 396e383286ccc368b54e980e06a506d339843594 Mon Sep 17 00:00:00 2001 From: Angelo capilleri Date: Tue, 15 May 2012 18:16:28 +0200 Subject: clean the errors if an object that includes validations errors is duped,for 3-2-stable It Fixes #5953 in 3-2-stable, it's the same pull request of #6284 --- activemodel/test/cases/validations_test.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'activemodel/test') diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb index 1941031e3c..56c9a5592c 100644 --- a/activemodel/test/cases/validations_test.rb +++ b/activemodel/test/cases/validations_test.rb @@ -339,4 +339,19 @@ class ValidationsTest < ActiveModel::TestCase end assert_equal "Title can't be blank", exception.message 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 -- cgit v1.2.3