Projects
openEuler:24.03:SP1:Everything:64G
rubygem-actionview
_service:tar_scm:rubygem-actionview-7.0.2.3-Fix...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:rubygem-actionview-7.0.2.3-Fix-tests-for-minitest-5.16.patch of Package rubygem-actionview
From 9766eb4a833c26c64012230b96dd1157ebb8e8a2 Mon Sep 17 00:00:00 2001 From: eileencodes <eileencodes@gmail.com> Date: Wed, 15 Jun 2022 12:44:11 -0400 Subject: [PATCH] Fix tests for minitest 5.16 In minitest/minitest@6e06ac9 minitest changed such that it now accepts `kwargs` instead of requiring kwargs to be shoved into the args array. This is a good change but required some updates to our test code to get the new version of minitest passing. Changes are as follows: 1) Lock minitest to 5.15 for Ruby 2.7. We don't love this change but it's pretty difficult to get 2.7 and 3.0 to play nicely together with the new kwargs changes. Dropping 2.7 support isn't an option right now for Rails. This is safe because all of the code changes here are internal methods to Rails like assert_called_with. Applications shouldn't be consuming them as they are no-doc'd. 2) Update the `assert_called_with` method to take any kwargs but also the returns kwarg. 3) Update callers of `assert_called_with` to move the kwargs outside the args array. 4) Update the message from marshaled exceptions. In 5.16 the exception message is "result not reported" instead of "Wrapped undumpable exception". Co-authored-by: Matthew Draper <matthew@trebex.net> --- .../test/template/date_helper_i18n_test.rb | 18 +-- .../template/form_helper/form_with_test.rb | 2 +- actionview/test/template/form_helper_test.rb | 2 +- .../template/form_options_helper_i18n_test.rb | 2 +- .../test/template/translation_helper_test.rb | 2 +- 16 files changed, 13 insertions(+), 13 deletions(-) diff --git a/actionview/test/template/date_helper_i18n_test.rb b/actionview/test/template/date_helper_i18n_test.rb index 2f098e2f5158f..819d0d0ac206b 100644 --- a/actionview/test/template/date_helper_i18n_test.rb +++ b/actionview/test/template/date_helper_i18n_test.rb @@ -49,7 +49,7 @@ def test_distance_of_time_in_words_calls_i18n_with_custom_scope end def test_time_ago_in_words_passes_locale - assert_called_with(I18n, :t, [:less_than_x_minutes, scope: :'datetime.distance_in_words', count: 1, locale: "ru"]) do + assert_called_with(I18n, :t, [:less_than_x_minutes], scope: :'datetime.distance_in_words', count: 1, locale: "ru") do time_ago_in_words(15.seconds.ago, locale: "ru") end end @@ -84,7 +84,7 @@ def assert_distance_of_time_in_words_translates_key(passed, expected, expected_o options = { locale: "en", scope: :'datetime.distance_in_words' }.merge!(expected_options) options[:count] = count if count - assert_called_with(I18n, :t, [key, options]) do + assert_called_with(I18n, :t, [key], **options) do distance_of_time_in_words(@from, to, passed_options.merge(locale: "en")) end end @@ -103,13 +103,13 @@ def test_select_month_given_use_month_names_option_does_not_translate_monthnames end def test_select_month_translates_monthnames - assert_called_with(I18n, :translate, [:'date.month_names', locale: "en"], returns: Date::MONTHNAMES) do + assert_called_with(I18n, :translate, [:'date.month_names'], returns: Date::MONTHNAMES, locale: "en") do select_month(8, locale: "en") end end def test_select_month_given_use_short_month_option_translates_abbr_monthnames - assert_called_with(I18n, :translate, [:'date.abbr_month_names', locale: "en"], returns: Date::ABBR_MONTHNAMES) do + assert_called_with(I18n, :translate, [:'date.abbr_month_names'], returns: Date::ABBR_MONTHNAMES, locale: "en") do select_month(8, locale: "en", use_short_month: true) end end @@ -147,8 +147,8 @@ def test_date_or_time_select_given_an_order_options_does_not_translate_order def test_date_or_time_select_given_no_order_options_translates_order mock = Minitest::Mock.new - mock.expect(:call, ["year", "month", "day"], [:'date.order', { locale: "en", default: [] }]) - mock.expect(:call, [], [:'date.month_names', { locale: "en" }]) + expect_called_with(mock, [:'date.order'], locale: "en", default: [], returns: ["year", "month", "day"]) + expect_called_with(mock, [:'date.month_names'], locale: "en", returns: []) I18n.stub(:translate, mock) do datetime_select("post", "updated_at", locale: "en") @@ -158,7 +158,7 @@ def test_date_or_time_select_given_no_order_options_translates_order end def test_date_or_time_select_given_invalid_order - assert_called_with(I18n, :translate, [:'date.order', locale: "en", default: []], returns: %w(invalid month day)) do + assert_called_with(I18n, :translate, [:'date.order'], returns: %w(invalid month day), locale: "en", default: []) do assert_raise StandardError do datetime_select("post", "updated_at", locale: "en") end @@ -167,8 +167,8 @@ def test_date_or_time_select_given_invalid_order def test_date_or_time_select_given_symbol_keys mock = Minitest::Mock.new - mock.expect(:call, [:year, :month, :day], [:'date.order', { locale: "en", default: [] }]) - mock.expect(:call, [], [:'date.month_names', { locale: "en" }]) + expect_called_with(mock, [:'date.order'], locale: "en", default: [], returns: [:year, :month, :day]) + expect_called_with(mock, [:'date.month_names'], locale: "en", returns: []) I18n.stub(:translate, mock) do datetime_select("post", "updated_at", locale: "en") diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb index 00e6ca42ea473..b3d6d59cd3afa 100644 --- a/actionview/test/template/form_helper/form_with_test.rb +++ b/actionview/test/template/form_helper/form_with_test.rb @@ -1747,7 +1747,7 @@ def test_nested_fields_label_translation_with_more_than_10_records mock = Minitest::Mock.new @post.comments.each do - mock.expect(:call, "body", ["post.comments.body", default: [:"comment.body", ""], scope: "helpers.label"]) + expect_called_with(mock, ["post.comments.body"], default: [:"comment.body", ""], scope: "helpers.label", returns: "body") end I18n.stub(:t, mock) do diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb index 8560be2770ca4..d8924d3e65004 100644 --- a/actionview/test/template/form_helper_test.rb +++ b/actionview/test/template/form_helper_test.rb @@ -3269,7 +3269,7 @@ def test_nested_fields_label_translation_with_more_than_10_records mock = Minitest::Mock.new @post.comments.each do - mock.expect(:call, "body", ["post.comments.body", default: [:"comment.body", ""], scope: "helpers.label"]) + expect_called_with(mock, ["post.comments.body"], default: [:"comment.body", ""], scope: "helpers.label", returns: "body") end I18n.stub(:t, mock) do diff --git a/actionview/test/template/form_options_helper_i18n_test.rb b/actionview/test/template/form_options_helper_i18n_test.rb index 21295fa547d8e..3dc625b8ac1df 100644 --- a/actionview/test/template/form_options_helper_i18n_test.rb +++ b/actionview/test/template/form_options_helper_i18n_test.rb @@ -16,7 +16,7 @@ def teardown end def test_select_with_prompt_true_translates_prompt_message - assert_called_with(I18n, :translate, ["helpers.select.prompt", { default: "Please select" }]) do + assert_called_with(I18n, :translate, ["helpers.select.prompt"], default: "Please select") do select("post", "category", [], prompt: true) end end diff --git a/actionview/test/template/translation_helper_test.rb b/actionview/test/template/translation_helper_test.rb index 9ed034113d0fb..b9da9174a517a 100644 --- a/actionview/test/template/translation_helper_test.rb +++ b/actionview/test/template/translation_helper_test.rb @@ -65,7 +65,7 @@ def test_delegates_setting_to_i18n def test_delegates_localize_to_i18n @time = Time.utc(2008, 7, 8, 12, 18, 38) - assert_called_with(I18n, :localize, [@time, locale: "en"]) do + assert_called_with(I18n, :localize, [@time], locale: "en") do localize @time, locale: "en" end assert_equal "Tue, 08 Jul 2008 12:18:38 +0000", localize(@time, locale: "en")
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2