aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/errors_test.rb
diff options
context:
space:
mode:
authorPaweł Kondzior <pawel@kondzior.com>2012-01-16 23:07:15 -0800
committerPaweł Kondzior <pawel@kondzior.com>2012-01-16 23:22:51 -0800
commit5313eab6954aff1235aca9126d662aac5b6c300d (patch)
treeabbdea13159ea0f1d4e5e7c2cc949678875ed694 /activemodel/test/cases/errors_test.rb
parent21afd9b96d70d1e2b1cffdfb60f7ec64ab240472 (diff)
downloadrails-5313eab6954aff1235aca9126d662aac5b6c300d.tar.gz
rails-5313eab6954aff1235aca9126d662aac5b6c300d.tar.bz2
rails-5313eab6954aff1235aca9126d662aac5b6c300d.zip
Fix ActiveModel::Errors#dup
Since ActiveModel::Errors instance keeps all error messages as hash we should duplicate this object as well. Previously ActiveModel::Errors was a subclass of ActiveSupport::OrderedHash, which results in different behavior on `dup`, this may result in regression for people relying on it.
Diffstat (limited to 'activemodel/test/cases/errors_test.rb')
-rw-r--r--activemodel/test/cases/errors_test.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activemodel/test/cases/errors_test.rb b/activemodel/test/cases/errors_test.rb
index 4edeece3e8..ab80f193b6 100644
--- a/activemodel/test/cases/errors_test.rb
+++ b/activemodel/test/cases/errors_test.rb
@@ -40,6 +40,14 @@ class ErrorsTest < ActiveModel::TestCase
assert errors.include?(:foo), 'errors should include :foo'
end
+ def test_dup
+ errors = ActiveModel::Errors.new(self)
+ errors[:foo] = 'bar'
+ errors_dup = errors.dup
+ errors_dup[:bar] = 'omg'
+ assert_not_same errors_dup.messages, errors.messages
+ end
+
def test_has_key?
errors = ActiveModel::Errors.new(self)
errors[:foo] = 'omg'