From 61e50814040d68c640b16afd2b9c419d2f12fad6 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 3 Dec 2015 21:18:57 +0300 Subject: `ActiveRecord::Base#becomes` should copy the errors --- activemodel/test/cases/errors_test.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'activemodel/test/cases') 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 -- cgit v1.2.3