aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases
diff options
context:
space:
mode:
authorVokhmin Alexey V <avokhmin@gmail.com>2015-12-03 21:18:57 +0300
committerVokhmin Alexey V <avokhmin@gmail.com>2015-12-14 19:02:20 +0300
commit61e50814040d68c640b16afd2b9c419d2f12fad6 (patch)
treeac4d6a8ec0694b968670fc5d872a6b258f0410b3 /activemodel/test/cases
parent574f255629a45cd67babcfb9bb8e163e091a53b8 (diff)
downloadrails-61e50814040d68c640b16afd2b9c419d2f12fad6.tar.gz
rails-61e50814040d68c640b16afd2b9c419d2f12fad6.tar.bz2
rails-61e50814040d68c640b16afd2b9c419d2f12fad6.zip
`ActiveRecord::Base#becomes` should copy the errors
Diffstat (limited to 'activemodel/test/cases')
-rw-r--r--activemodel/test/cases/errors_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activemodel/test/cases/errors_test.rb b/activemodel/test/cases/errors_test.rb
index f6d171bec6..a5ac055033 100644
--- a/activemodel/test/cases/errors_test.rb
+++ b/activemodel/test/cases/errors_test.rb
@@ -410,4 +410,14 @@ class ErrorsTest < ActiveModel::TestCase
person.errors.clear
assert person.errors.details.empty?
end
+
+ test "copy errors" do
+ errors = ActiveModel::Errors.new(Person.new)
+ errors.add(:name, :invalid)
+ person = Person.new
+ person.errors.copy!(errors)
+
+ assert_equal [:name], person.errors.messages.keys
+ assert_equal [:name], person.errors.details.keys
+ end
end