From 94e4f067eb6b5fb9297ba3eb1f14d835995032c1 Mon Sep 17 00:00:00 2001 From: Fiona Date: Fri, 20 Nov 2026 11:17:08 -0500 Subject: [PATCH 1/4] Update ruby to 4.0.10 --- .ruby-version | 2 +- .tool-versions | 2 +- Dockerfile | 2 +- Gemfile.lock | 2 +- Gemfile.next.lock | 2 +- README.md | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.ruby-version b/.ruby-version index c5106e6..2d2d681 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -4.0.4 +4.0.10 diff --git a/.tool-versions b/.tool-versions index 75d5860..7fa1ac0 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -ruby 4.0.4 +ruby 4.0.10 nodejs 24.18.0 diff --git a/Dockerfile b/Dockerfile index a1603af..ea81831 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1 -FROM ruby:4.0.4 +FROM ruby:4.0.10 RUN dpkg --add-architecture i386 \ && apt-get update -qq \ diff --git a/Gemfile.lock b/Gemfile.lock index 26b2ddf..98be963 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -453,7 +453,7 @@ DEPENDENCIES wkhtmltopdf-binary (= 0.12.3.1) RUBY VERSION - ruby 4.0.4 + ruby 4.0.10 BUNDLED WITH 4.0.15 diff --git a/Gemfile.next.lock b/Gemfile.next.lock index 26b2ddf..98be963 100644 --- a/Gemfile.next.lock +++ b/Gemfile.next.lock @@ -453,7 +453,7 @@ DEPENDENCIES wkhtmltopdf-binary (= 0.12.3.1) RUBY VERSION - ruby 4.0.4 + ruby 4.0.10 BUNDLED WITH 4.0.15 diff --git a/README.md b/README.md index c1d55d0..5afe8c9 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ You can see it working in https://audit.fastruby.io ## Requirements -- Ruby version `4.0.4` (see `.ruby-version` / `.tool-versions`) +- Ruby version `4.0.10` (see `.ruby-version` / `.tool-versions`) - Node version `24.18.0` (see `.tool-versions`) - Docker + Docker Compose (recommended for local development) From c89e1a7b630d516636227b7e5eb98935ed2fedd1 Mon Sep 17 00:00:00 2001 From: Fiona Date: Fri, 20 Nov 2026 11:51:32 -0500 Subject: [PATCH 2/4] Capybara patch --- test/test_helper.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index c134b03..322eea7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,5 +1,6 @@ require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' +require "capybara" class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. @@ -9,3 +10,29 @@ class ActiveSupport::TestCase FileUtils.rm_rf(Rails.root.join("test/test_files")) end end + +# Remove this when a new Capybara version solvind this issue is released +# https://github.com/teamcapybara/capybara/pull/2868 +# https://github.com/teamcapybara/capybara/pull/2867 +Capybara::Selenium::Driver::ChromeDriver.class_eval do + def reset! + # Use instance variable directly so we avoid starting the browser just to reset the session + return unless @browser + + switch_to_window(window_handles.first) + window_handles.slice(1..).each { |win| close_window(win) } + return super if chromedriver_version < 73 + + timer = Capybara::Helpers.timer(expire_in: 10) + begin + clear_storage unless uniform_storage_clear? + @browser.navigate.to('about:blank') + wait_for_empty_page(timer) + rescue *unhandled_alert_errors + accept_unhandled_reset_alert + retry + end + + execute_cdp('Storage.clearDataForOrigin', origin: "http://127.0.0.1", storageTypes: storage_types_to_clear) + end +end From 545ed32a459c83a5541cdea6818f50bfd67c9a84 Mon Sep 17 00:00:00 2001 From: Fiona Date: Fri, 20 Nov 2026 12:21:58 -0500 Subject: [PATCH 3/4] Ignore reek --- test/test_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index 322eea7..97bf2a1 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -15,6 +15,8 @@ class ActiveSupport::TestCase # https://github.com/teamcapybara/capybara/pull/2868 # https://github.com/teamcapybara/capybara/pull/2867 Capybara::Selenium::Driver::ChromeDriver.class_eval do + # Mirrors Capybara's upstream reset!, so keep its shape rather than splitting it up. + # :reek:TooManyStatements def reset! # Use instance variable directly so we avoid starting the browser just to reset the session return unless @browser From d4c91231affb72c64cd849461b8293a5d21ec079 Mon Sep 17 00:00:00 2001 From: Francois Buys Date: Sat, 21 Nov 2026 01:04:13 +0200 Subject: [PATCH 4/4] Fix Capybara reset! patch to clear the app's origin Storage.clearDataForOrigin only matches an exact origin, which includes the port. The hardcoded "http://127.0.0.1" never matched the random-port test server, so cookies and localStorage carried over between system tests. With Capybara's default options, this call is the only thing that clears them. - Use Capybara's server base_url as the origin, and skip the call when there is no server - Only apply the patch while Capybara is 3.40.0 or older, so a fixed release replaces it automatically - Move the patch from test_helper.rb to application_system_test_case.rb so unit tests don't load Capybara --- test/application_system_test_case.rb | 35 ++++++++++++++++++++++++++++ test/test_helper.rb | 29 ----------------------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index 38a39f5..188ba9a 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -36,6 +36,41 @@ Capybara::Selenium::Driver.new(app, browser: :chrome, options: options, service: service) end +# Capybara 3.40.0 clears storage with `origin: "*"`, which recent Chrome +# rejects. Clear the app server's origin instead. The version guard turns this +# off once a Capybara release with the fix is installed. +# https://github.com/teamcapybara/capybara/pull/2867 +# https://github.com/teamcapybara/capybara/pull/2868 +if Gem::Version.new(Capybara::VERSION) <= Gem::Version.new("3.40.0") + Capybara::Selenium::Driver::ChromeDriver.class_eval do + # Mirrors Capybara's upstream reset!, so keep its shape rather than splitting it up. + # :reek:TooManyStatements + def reset! + # Use instance variable directly so we avoid starting the browser just to reset the session + return unless @browser + + switch_to_window(window_handles.first) + window_handles.slice(1..).each { |win| close_window(win) } + return super if chromedriver_version < 73 + + timer = Capybara::Helpers.timer(expire_in: 10) + begin + clear_storage unless uniform_storage_clear? + @browser.navigate.to('about:blank') + wait_for_empty_page(timer) + rescue *unhandled_alert_errors + accept_unhandled_reset_alert + retry + end + + # base_url includes the random port Capybara's server listens on, which + # Storage.clearDataForOrigin needs to match the app's storage. + origin = Capybara.current_session.server&.base_url + execute_cdp('Storage.clearDataForOrigin', origin: origin, storageTypes: storage_types_to_clear) if origin + end + end +end + class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :headless_chromium end diff --git a/test/test_helper.rb b/test/test_helper.rb index 97bf2a1..c134b03 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,5 @@ require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' -require "capybara" class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. @@ -10,31 +9,3 @@ class ActiveSupport::TestCase FileUtils.rm_rf(Rails.root.join("test/test_files")) end end - -# Remove this when a new Capybara version solvind this issue is released -# https://github.com/teamcapybara/capybara/pull/2868 -# https://github.com/teamcapybara/capybara/pull/2867 -Capybara::Selenium::Driver::ChromeDriver.class_eval do - # Mirrors Capybara's upstream reset!, so keep its shape rather than splitting it up. - # :reek:TooManyStatements - def reset! - # Use instance variable directly so we avoid starting the browser just to reset the session - return unless @browser - - switch_to_window(window_handles.first) - window_handles.slice(1..).each { |win| close_window(win) } - return super if chromedriver_version < 73 - - timer = Capybara::Helpers.timer(expire_in: 10) - begin - clear_storage unless uniform_storage_clear? - @browser.navigate.to('about:blank') - wait_for_empty_page(timer) - rescue *unhandled_alert_errors - accept_unhandled_reset_alert - retry - end - - execute_cdp('Storage.clearDataForOrigin', origin: "http://127.0.0.1", storageTypes: storage_types_to_clear) - end -end