From 69eb40551fdf9b8bb5b8f1f244c50c496bfb53c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?=
 <rafael@rubyonrails.org>
Date: Thu, 25 Nov 2021 22:18:02 +0000
Subject: [PATCH 1/6] Try upgrade rubygems as well to see if it fix the CI

---
 .github/workflows/ci.yml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a37eb440..4359ea2f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -28,6 +28,11 @@ jobs:
           ruby-version: ${{ matrix.ruby }}
           bundler-cache: true
 
+      - name: Run unit tests
+        run: gem update --system
+        timeout-minutes: 3
+        if: ${{ matrix.ruby == '3.0' }} Ruby 3.0.3 has a bug with old Rubygems
+
       - name: Run unit tests
         run: bundle exec rake test:unit
         timeout-minutes: 3

From aad904ce525d505e6f7b70ffa6acafe32d8e90a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?=
 <rafael@rubyonrails.org>
Date: Thu, 25 Nov 2021 22:23:36 +0000
Subject: [PATCH 2/6] Use newest bundler

---
 .github/workflows/ci.yml    | 5 -----
 test/support/application.rb | 5 +----
 2 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 4359ea2f..a37eb440 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -28,11 +28,6 @@ jobs:
           ruby-version: ${{ matrix.ruby }}
           bundler-cache: true
 
-      - name: Run unit tests
-        run: gem update --system
-        timeout-minutes: 3
-        if: ${{ matrix.ruby == '3.0' }} Ruby 3.0.3 has a bug with old Rubygems
-
       - name: Run unit tests
         run: bundle exec rake test:unit
         timeout-minutes: 3
diff --git a/test/support/application.rb b/test/support/application.rb
index bd91e8a2..955c3624 100644
--- a/test/support/application.rb
+++ b/test/support/application.rb
@@ -220,10 +220,7 @@ def run!(command, options = {})
       end
 
       def bundle
-        # Version restriction is a workaround for https://github.com/bundler/bundler/pull/4981
-        # The problem breaks our tests on Ruby 2.2
-        # We can remove once it's fixed
-        run! "(gem list bundler | grep bundler) || gem install bundler --version '~> 1.12.0'", timeout: nil, retry: 2
+        run! "(gem list bundler | grep bundler) || gem install bundler", timeout: nil, retry: 2
         run! "bundle check || bundle update --retry=2", timeout: nil
       end
 

From ad39bba63484aae4f730c41fbb138744dd3f5dde Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?=
 <rafael@rubyonrails.org>
Date: Thu, 25 Nov 2021 22:30:28 +0000
Subject: [PATCH 3/6] Use 3.0.2 instead of 3.0.3

---
 .github/workflows/ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a37eb440..728ecd83 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -6,7 +6,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        ruby: [ '2.7', '3.0', 'head' ]
+        ruby: [ '2.7', '3.0.2', 'head' ]
         rails: [ '6.0', '6.1', 'edge' ]
         include:
           - ruby: '2.6'

From 8c06e9fa0e32adfd23b19e2d1a7771e55b8f3b3f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?=
 <rafael@rubyonrails.org>
Date: Thu, 25 Nov 2021 22:35:34 +0000
Subject: [PATCH 4/6] Try with the original env

---
 test/support/application.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/support/application.rb b/test/support/application.rb
index 955c3624..5583c744 100644
--- a/test/support/application.rb
+++ b/test/support/application.rb
@@ -111,7 +111,7 @@ def spring_client_config
       def run(command, opts = {})
         start_time = Time.now
 
-        Bundler.with_clean_env do
+        Bundler.with_original_env do
           Process.spawn(
             env.merge(opts[:env] || {}),
             command.to_s,

From 22b5a107eacf9174856d84a710eaac49f2360948 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?=
 <rafael@rubyonrails.org>
Date: Thu, 25 Nov 2021 22:36:00 +0000
Subject: [PATCH 5/6] But with Ruby 3.0.3

---
 .github/workflows/ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 728ecd83..a37eb440 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -6,7 +6,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        ruby: [ '2.7', '3.0.2', 'head' ]
+        ruby: [ '2.7', '3.0', 'head' ]
         rails: [ '6.0', '6.1', 'edge' ]
         include:
           - ruby: '2.6'

From 1d400bc64b62a1fecb920a0a6fce995b892bf414 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?=
 <rafael@rubyonrails.org>
Date: Thu, 25 Nov 2021 22:47:19 +0000
Subject: [PATCH 6/6] Use original env also in the application generator

---
 test/support/application_generator.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/support/application_generator.rb b/test/support/application_generator.rb
index 2485385c..13d85277 100644
--- a/test/support/application_generator.rb
+++ b/test/support/application_generator.rb
@@ -31,7 +31,7 @@ def system(command)
       end
 
       def generate
-        Bundler.with_clean_env { generate_files }
+        Bundler.with_original_env { generate_files }
         install_spring
         generate_scaffold
       end
