aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/errors_test.rb
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-07-07 16:21:05 -0400
committerGitHub <noreply@github.com>2017-07-07 16:21:05 -0400
commit98f8f81879825a009b0c751b3178fcb687e3033a (patch)
treea374621870fb12dfc9eab3e8c67294175c081a9d /activemodel/test/cases/errors_test.rb
parent44f3ecbe5f3cb531164ed9bb14c58781281113ee (diff)
parent3650ca983c5c2ffd1a2993fa091bf504594325a7 (diff)
downloadrails-98f8f81879825a009b0c751b3178fcb687e3033a.tar.gz
rails-98f8f81879825a009b0c751b3178fcb687e3033a.tar.bz2
rails-98f8f81879825a009b0c751b3178fcb687e3033a.zip
Merge pull request #29714 from jahfer/implement-errors-merge
Add ActiveModel::Errors#merge!
Diffstat (limited to 'activemodel/test/cases/errors_test.rb')
-rw-r--r--activemodel/test/cases/errors_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activemodel/test/cases/errors_test.rb b/activemodel/test/cases/errors_test.rb
index 43aee5a814..7383b3e9b0 100644
--- a/activemodel/test/cases/errors_test.rb
+++ b/activemodel/test/cases/errors_test.rb
@@ -375,6 +375,18 @@ class ErrorsTest < ActiveModel::TestCase
assert_equal [:name], person.errors.details.keys
end
+ test "merge errors" do
+ errors = ActiveModel::Errors.new(Person.new)
+ errors.add(:name, :invalid)
+
+ person = Person.new
+ person.errors.add(:name, :blank)
+ person.errors.merge!(errors)
+
+ assert_equal({ name: ["can't be blank", "is invalid"] }, person.errors.messages)
+ assert_equal({ name: [{ error: :blank }, { error: :invalid }] }, person.errors.details)
+ end
+
test "errors are marshalable" do
errors = ActiveModel::Errors.new(Person.new)
errors.add(:name, :invalid)