aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorEdouard CHIN <edouard.chin@shopify.com>2019-07-09 14:40:57 +0200
committerEdouard CHIN <edouard.chin@shopify.com>2019-07-16 14:28:38 +0200
commitb677adede027eefed41f6b37096df7bbc4eb3d38 (patch)
tree4721c73ed25b7445db1ffa394ac7b6b584919d7a /activerecord
parent5a9301ce47f1117c8d457cad2b850f932bf7f518 (diff)
downloadrails-b677adede027eefed41f6b37096df7bbc4eb3d38.tar.gz
rails-b677adede027eefed41f6b37096df7bbc4eb3d38.tar.bz2
rails-b677adede027eefed41f6b37096df7bbc4eb3d38.zip
Move the `ActiveModel:Errors#full_message` method to the `Error` class:
- One regression introduced by the "AM errors as object" features is about the `full_messages` method. It's currently impossible to call that method if the `base` object passed in the constructor of `AM::Errors` doesn't respond to the `errors` method. That's because `full_messages` now makes a weird back and forth trip `AM::Errors#full_messages` -> `AM::Error#full_message` -> `AM::Errors#full_message` Since `full_message` (singular) isn't needed by AM::Errors, I moved it to the `AM::Error` (singular) class. This way we don't need to grab the `AM::Errors` object from the base.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/validations/i18n_validation_test.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/test/cases/validations/i18n_validation_test.rb b/activerecord/test/cases/validations/i18n_validation_test.rb
index 2645776ab7..4dd8a4a82b 100644
--- a/activerecord/test/cases/validations/i18n_validation_test.rb
+++ b/activerecord/test/cases/validations/i18n_validation_test.rb
@@ -51,7 +51,7 @@ class I18nValidationTest < ActiveRecord::TestCase
test "validates_uniqueness_of on generated message #{name}" do
Topic.validates_uniqueness_of :title, validation_options
@topic.title = unique_topic.title
- assert_called_with(@topic.errors, :generate_message, [:title, :taken, generate_message_options.merge(value: "unique!")]) do
+ assert_called_with(ActiveModel::Error, :generate_message, [:title, :taken, @topic, generate_message_options.merge(value: "unique!")]) do
@topic.valid?
@topic.errors.messages
end
@@ -61,7 +61,7 @@ class I18nValidationTest < ActiveRecord::TestCase
COMMON_CASES.each do |name, validation_options, generate_message_options|
test "validates_associated on generated message #{name}" do
Topic.validates_associated :replies, validation_options
- assert_called_with(replied_topic.errors, :generate_message, [:replies, :invalid, generate_message_options.merge(value: replied_topic.replies)]) do
+ assert_called_with(ActiveModel::Error, :generate_message, [:replies, :invalid, replied_topic, generate_message_options.merge(value: replied_topic.replies)]) do
replied_topic.save
replied_topic.errors.messages
end