diff options
Diffstat (limited to 'activemodel/test/cases/validations_test.rb')
-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 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 |