代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/rubygem-actionview 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From df0de681dc1873534ecd2fc8371e1f2562984b68 Mon Sep 17 00:00:00 2001
From: John Crepezzi <john.crepezzi@gmail.com>
Date: Thu, 16 Jun 2022 08:34:05 -0400
Subject: [PATCH] Remove the multi-call form of assert_called_with
The `assert_called_with` helper allows passing a multi-dimensional array to
mock multiple calls to the same method for a given block. This works
fine now, but when adding support for real kwargs arguments to line up with
recent upgrades in Minitest, this approach is no longer workable because
we can't pass multiple sets of differing kwargs.
Rather than complicated this method further, this commit removes the
multi-call form of `assert_called_with` and modifies the tests that
currently make use of that functionality to just use the underlying
`Minitest::Mock` calls.
Co-authored-by: Eileen M. Uchitelle <eileencodes@gmail.com>
---
.../test/template/date_helper_i18n_test.rb | 16 +++-
.../template/form_helper/form_with_test.rb | 10 ++-
actionview/test/template/form_helper_test.rb | 10 ++-
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/actionview/test/template/date_helper_i18n_test.rb b/actionview/test/template/date_helper_i18n_test.rb
index f100a011a83f7..2f098e2f5158f 100644
--- a/actionview/test/template/date_helper_i18n_test.rb
+++ b/actionview/test/template/date_helper_i18n_test.rb
@@ -146,9 +146,15 @@ def test_date_or_time_select_given_an_order_options_does_not_translate_order
end
def test_date_or_time_select_given_no_order_options_translates_order
- assert_called_with(I18n, :translate, [ [:'date.order', locale: "en", default: []], [:"date.month_names", { locale: "en" }] ], returns: %w(year month day)) do
+ mock = Minitest::Mock.new
+ mock.expect(:call, ["year", "month", "day"], [:'date.order', { locale: "en", default: [] }])
+ mock.expect(:call, [], [:'date.month_names', { locale: "en" }])
+
+ I18n.stub(:translate, mock) do
datetime_select("post", "updated_at", locale: "en")
end
+
+ assert_mock(mock)
end
def test_date_or_time_select_given_invalid_order
@@ -160,8 +166,14 @@ def test_date_or_time_select_given_invalid_order
end
def test_date_or_time_select_given_symbol_keys
- assert_called_with(I18n, :translate, [ [:'date.order', locale: "en", default: []], [:"date.month_names", { locale: "en" }] ], returns: [:year, :month, :day]) do
+ mock = Minitest::Mock.new
+ mock.expect(:call, [:year, :month, :day], [:'date.order', { locale: "en", default: [] }])
+ mock.expect(:call, [], [:'date.month_names', { locale: "en" }])
+
+ I18n.stub(:translate, mock) do
datetime_select("post", "updated_at", locale: "en")
end
+
+ assert_mock(mock)
end
end
diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb
index eadddc15002ee..00e6ca42ea473 100644
--- a/actionview/test/template/form_helper/form_with_test.rb
+++ b/actionview/test/template/form_helper/form_with_test.rb
@@ -1745,14 +1745,20 @@ def test_nested_fields_arel_like
def test_nested_fields_label_translation_with_more_than_10_records
@post.comments = Array.new(11) { |id| Comment.new(id + 1) }
- params = 11.times.map { ["post.comments.body", default: [:"comment.body", ""], scope: "helpers.label"] }
- assert_called_with(I18n, :t, params, returns: "Write body here") do
+ mock = Minitest::Mock.new
+ @post.comments.each do
+ mock.expect(:call, "body", ["post.comments.body", default: [:"comment.body", ""], scope: "helpers.label"])
+ end
+
+ I18n.stub(:t, mock) do
form_with(model: @post) do |f|
f.fields(:comments) do |cf|
concat cf.label(:body)
end
end
end
+
+ assert_mock(mock)
end
def test_nested_fields_with_existing_records_on_a_supplied_nested_attributes_collection_different_from_record_one
diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb
index d08f00cd36c35..8560be2770ca4 100644
--- a/actionview/test/template/form_helper_test.rb
+++ b/actionview/test/template/form_helper_test.rb
@@ -3267,14 +3267,20 @@ def test_nested_fields_for_arel_like
def test_nested_fields_label_translation_with_more_than_10_records
@post.comments = Array.new(11) { |id| Comment.new(id + 1) }
- params = 11.times.map { ["post.comments.body", default: [:"comment.body", ""], scope: "helpers.label"] }
- assert_called_with(I18n, :t, params, returns: "Write body here") do
+ mock = Minitest::Mock.new
+ @post.comments.each do
+ mock.expect(:call, "body", ["post.comments.body", default: [:"comment.body", ""], scope: "helpers.label"])
+ end
+
+ I18n.stub(:t, mock) do
form_for(@post) do |f|
f.fields_for(:comments) do |cf|
concat cf.label(:body)
end
end
end
+
+ assert_mock(mock)
end
def test_nested_fields_for_with_existing_records_on_a_supplied_nested_attributes_collection_different_from_record_one
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。