From fb7d95b21222f762eb4dded727a5999fb198fdfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Wn=C4=99trzak?= Date: Sat, 24 Jan 2015 11:58:52 +0100 Subject: [PATCH] Fixed duplicating ActiveModel::Errors#details --- activemodel/lib/active_model/errors.rb | 3 ++- activemodel/test/cases/errors_test.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 912448e43c..a809c72ccd 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -2,6 +2,7 @@ require 'active_support/core_ext/array/conversions' require 'active_support/core_ext/string/inflections' +require 'active_support/core_ext/object/deep_dup' module ActiveModel # == Active \Model \Errors @@ -77,7 +78,7 @@ module ActiveModel def initialize_dup(other) # :nodoc: @messages = other.messages.dup - @details = other.details.dup + @details = other.details.deep_dup super end diff --git a/activemodel/test/cases/errors_test.rb b/activemodel/test/cases/errors_test.rb index 9cfba9812b..17dbb817d0 100644 --- a/activemodel/test/cases/errors_test.rb +++ b/activemodel/test/cases/errors_test.rb @@ -347,7 +347,7 @@ class ErrorsTest < ActiveModel::TestCase errors.add(:name, :invalid) errors_dup = errors.dup errors_dup.add(:name, :taken) - assert_not_same errors_dup.details, errors.details + assert_not_equal errors_dup.details, errors.details end test "delete removes details on given attribute" do