From 5d64851ad054ecc24bee0371203b6eb0e60d28b2 Mon Sep 17 00:00:00 2001 From: Jolyon Pawlyn Date: Thu, 16 Dec 2021 15:15:40 +0200 Subject: [PATCH] Prevent the clearing of instance variables after each test request with Rails 7 --- test/support/rails_7_patch.rb | 13 +++++++++++++ test/test_helper.rb | 1 + 2 files changed, 14 insertions(+) create mode 100644 test/support/rails_7_patch.rb diff --git a/test/support/rails_7_patch.rb b/test/support/rails_7_patch.rb new file mode 100644 index 00000000..b2cc74ab --- /dev/null +++ b/test/support/rails_7_patch.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# HACK: to prevent the resetting of instance variables after each request in Rails 7 +# see https://github.com/rails/rails/pull/43735 +if Rails::VERSION::MAJOR >= 7 + module ActionController + module Testing + module Functional + def clear_instance_variables_between_requests; end + end + end + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 7d8ca63e..00123504 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -49,6 +49,7 @@ end require 'support/rails_app' +require 'support/rails_7_patch' require 'support/ruby_2_6_rails_4_2_patch' # require "rails/test_help"