From 655036b09a99daaa5b5f77777f23fc13829919b0 Mon Sep 17 00:00:00 2001 From: lulalala Date: Sun, 31 Mar 2019 16:31:34 +0800 Subject: Fix spec as generate_message is no longer called during validation --- .../test/cases/validations/i18n_validation_test.rb | 15 +++++++++++++++ .../test/cases/validations/i18n_validation_test.rb | 2 ++ 2 files changed, 17 insertions(+) diff --git a/activemodel/test/cases/validations/i18n_validation_test.rb b/activemodel/test/cases/validations/i18n_validation_test.rb index f68219b4b6..c94b27c23c 100644 --- a/activemodel/test/cases/validations/i18n_validation_test.rb +++ b/activemodel/test/cases/validations/i18n_validation_test.rb @@ -179,6 +179,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title_confirmation, :confirmation, generate_message_options.merge(attribute: "Title")] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end @@ -189,6 +190,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title, :accepted, generate_message_options] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end @@ -199,6 +201,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title, :blank, generate_message_options] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end @@ -209,6 +212,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title, :too_short, generate_message_options.merge(count: 3)] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end @@ -220,6 +224,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title, :too_long, generate_message_options.merge(count: 5)] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end @@ -230,6 +235,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title, :wrong_length, generate_message_options.merge(count: 5)] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end @@ -241,6 +247,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title, :invalid, generate_message_options.merge(value: "72x")] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end @@ -252,6 +259,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title, :inclusion, generate_message_options.merge(value: "z")] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end @@ -263,6 +271,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title, :inclusion, generate_message_options.merge(value: "z")] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end @@ -274,6 +283,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title, :exclusion, generate_message_options.merge(value: "a")] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end @@ -285,6 +295,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title, :exclusion, generate_message_options.merge(value: "a")] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end @@ -296,6 +307,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title, :not_a_number, generate_message_options.merge(value: "a")] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end @@ -307,6 +319,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title, :not_an_integer, generate_message_options.merge(value: "0.0")] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end @@ -318,6 +331,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title, :odd, generate_message_options.merge(value: 0)] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end @@ -329,6 +343,7 @@ class I18nValidationTest < ActiveModel::TestCase call = [:title, :less_than, generate_message_options.merge(value: 1, count: 0)] assert_called_with(@person.errors, :generate_message, call) do @person.valid? + @person.errors.messages end end end diff --git a/activerecord/test/cases/validations/i18n_validation_test.rb b/activerecord/test/cases/validations/i18n_validation_test.rb index 467f4b268a..2645776ab7 100644 --- a/activerecord/test/cases/validations/i18n_validation_test.rb +++ b/activerecord/test/cases/validations/i18n_validation_test.rb @@ -53,6 +53,7 @@ class I18nValidationTest < ActiveRecord::TestCase @topic.title = unique_topic.title assert_called_with(@topic.errors, :generate_message, [:title, :taken, generate_message_options.merge(value: "unique!")]) do @topic.valid? + @topic.errors.messages end end end @@ -62,6 +63,7 @@ class I18nValidationTest < ActiveRecord::TestCase 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 replied_topic.save + replied_topic.errors.messages end end end -- cgit v1.2.3