!12 upgrade to version 7.0.4

From: @yanxiaobing2020 
Reviewed-by: @jxy_git 
Signed-off-by: @jxy_git
This commit is contained in:
openeuler-ci-bot 2023-01-20 02:58:40 +00:00 committed by Gitee
commit 932cb50b93
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 178 additions and 6 deletions

Binary file not shown.

BIN
activesupport-7.0.4.gem Normal file

Binary file not shown.

View File

@ -0,0 +1,72 @@
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>
---
.../testing/method_call_assertions.rb | 22 +++-
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/activesupport/lib/active_support/testing/method_call_assertions.rb b/activesupport/lib/active_support/testing/method_call_assertions.rb
index 72451faaa8cc4..f146eefce0354 100644
--- a/activesupport/lib/active_support/testing/method_call_assertions.rb
+++ b/activesupport/lib/active_support/testing/method_call_assertions.rb
@@ -17,9 +17,9 @@ def assert_called(object, method_name, message = nil, times: 1, returns: nil, &b
assert_equal times, times_called, error
end
- def assert_called_with(object, method_name, args, returns: nil, &block)
+ def assert_called_with(object, method_name, args, returns: false, **kwargs, &block)
mock = Minitest::Mock.new
- mock.expect(:call, returns, args)
+ expect_called_with(mock, args, returns: returns, **kwargs)
object.stub(method_name, mock, &block)
@@ -30,6 +30,24 @@ def assert_not_called(object, method_name, message = nil, &block)
assert_called(object, method_name, message, times: 0, &block)
end
+ #--
+ # This method is a temporary wrapper for mock.expect as part of
+ # the Minitest 5.16 / Ruby 3.0 kwargs transition. It can go away
+ # when we drop support for Ruby 2.7.
+ if Minitest::Mock.instance_method(:expect).parameters.map(&:first).include?(:keyrest)
+ def expect_called_with(mock, args, returns: false, **kwargs)
+ mock.expect(:call, returns, args, **kwargs)
+ end
+ else
+ def expect_called_with(mock, args, returns: false, **kwargs)
+ if !kwargs.empty?
+ mock.expect(:call, returns, [*args, kwargs])
+ else
+ mock.expect(:call, returns, args)
+ end
+ end
+ end
+
def assert_called_on_instance_of(klass, method_name, message = nil, times: 1, returns: nil)
times_called = 0
klass.define_method("stubbed_#{method_name}") do |*|

View File

@ -0,0 +1,39 @@
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>
---
.../testing/method_call_assertions_test.rb | 7 --
1 file changed, 7 deletions(-)
diff --git a/activesupport/test/testing/method_call_assertions_test.rb b/activesupport/test/testing/method_call_assertions_test.rb
index e75630d2e4228..4d59e0bd3c222 100644
--- a/activesupport/test/testing/method_call_assertions_test.rb
+++ b/activesupport/test/testing/method_call_assertions_test.rb
@@ -82,13 +82,6 @@ def test_assert_called_with_failure
end
end
- def test_assert_called_with_multiple_expected_arguments
- assert_called_with(@object, :<<, [ [ 1 ], [ 2 ] ]) do
- @object << 1
- @object << 2
- end
- end
-
def test_assert_called_on_instance_of_with_defaults_to_expect_once
assert_called_on_instance_of Level, :increment do
@object.increment

View File

@ -0,0 +1,39 @@
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>
---
.../testing/method_call_assertions.rb | 7 +-
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/activesupport/lib/active_support/testing/method_call_assertions.rb b/activesupport/lib/active_support/testing/method_call_assertions.rb
index c8d2dbaa52ab5..72451faaa8cc4 100644
--- a/activesupport/lib/active_support/testing/method_call_assertions.rb
+++ b/activesupport/lib/active_support/testing/method_call_assertions.rb
@@ -19,12 +19,7 @@ def assert_called(object, method_name, message = nil, times: 1, returns: nil, &b
def assert_called_with(object, method_name, args, returns: nil, &block)
mock = Minitest::Mock.new
-
- if args.all?(Array)
- args.each { |arg| mock.expect(:call, returns, arg) }
- else
- mock.expect(:call, returns, args)
- end
+ mock.expect(:call, returns, args)
object.stub(method_name, mock, &block)

View File

@ -1,15 +1,29 @@
%global gem_name activesupport %global gem_name activesupport
Name: rubygem-%{gem_name} Name: rubygem-%{gem_name}
Epoch: 1 Epoch: 1
Version: 6.1.4.1 Version: 7.0.4
Release: 2 Release: 1
Summary: A support libraries and Ruby core extensions extracted from the Rails framework Summary: A support libraries and Ruby core extensions extracted from the Rails framework
License: MIT License: MIT
URL: http://rubyonrails.org URL: http://rubyonrails.org
Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
# The activesupport gem doesn't ship with the test suite.
# You may check it out like so
# git clone http://github.com/rails/rails.git
# cd rails/activesupport && git archive -v -o activesupport-7.0.4-tests.txz v7.0.4 test/
Source1: %{gem_name}-%{version}-tests.txz Source1: %{gem_name}-%{version}-tests.txz
# The tools are needed for the test suite, are however unpackaged in gem file.
# You may get them like so
# git clone http://github.com/rails/rails.git --no-checkout
# cd rails && git archive -v -o rails-7.0.4-tools.txz v7.0.4 tools/
Source2: rails-%{version}-tools.txz Source2: rails-%{version}-tools.txz
Patch0: Add-support-dalli-3.2.2.patch # Fixes for Minitest 5.16+
# https://github.com/rails/rails/pull/45380
Patch1: rubygem-activesupport-7.0.2.3-Remove-the-multi-call-form-of-assert_called_with.patch
Patch2: rubygem-activesupport-7.0.2.3-Remove-the-multi-call-form-of-assert_called_with-test.patch
# https://github.com/rails/rails/pull/45370
Patch3: rubygem-activesupport-7.0.2.3-Fix-tests-for-minitest-5.16.patch
Requires: rubygem(bigdecimal) rubygem(json) Requires: rubygem(bigdecimal) rubygem(json)
BuildRequires: ruby(release) rubygems-devel ruby >= 2.2.2 rubygem(bigdecimal) rubygem(builder) BuildRequires: ruby(release) rubygems-devel ruby >= 2.2.2 rubygem(bigdecimal) rubygem(builder)
BuildRequires: rubygem(concurrent-ruby) rubygem(connection_pool) rubygem(dalli) BuildRequires: rubygem(concurrent-ruby) rubygem(connection_pool) rubygem(dalli)
@ -30,8 +44,11 @@ Documentation for %{name}.
%prep %prep
%setup -q -n %{gem_name}-%{version} -b1 -b2 %setup -q -n %{gem_name}-%{version} -b1 -b2
pushd %{_builddir}/test %patch1 -p2
%patch0 -p1 %patch3 -p2
pushd %{_builddir}
%patch2 -p2
popd popd
%build %build
@ -47,9 +64,11 @@ cp -a .%{gem_dir}/* \
pushd .%{gem_instdir} pushd .%{gem_instdir}
ln -s %{_builddir}/tools .. ln -s %{_builddir}/tools ..
mv %{_builddir}/test . mv %{_builddir}/test .
# redis_cache_store_test: failed to require "redis/connection/hiredis"
for f in \ for f in \
test/evented_file_update_checker_test.rb \ test/evented_file_update_checker_test.rb \
test/cache/stores/redis_cache_store_test.rb # failed to require "redis/connection/hiredis" test/cache/stores/redis_cache_store_test.rb \
test/cache/stores/mem_cache_store_test.rb
do do
mv $f{,.disable} mv $f{,.disable}
done done
@ -76,6 +95,9 @@ popd
%doc %{gem_instdir}/README.rdoc %doc %{gem_instdir}/README.rdoc
%changelog %changelog
* Thu Jan 19 2023 yanxiaobing <yanxiaobing@huawei.com> - 1:7.0.4-1
- Upgrade to version 7.0.4
* Tue Jul 05 2022 liyanan <liyanan32@h-partners.com> - 6.1.4.1-2 * Tue Jul 05 2022 liyanan <liyanan32@h-partners.com> - 6.1.4.1-2
- Add support dalli 3.2.2 - Add support dalli 3.2.2