From 4d256b8a4e9c976ce9fbc2f58692bd8abb197485 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Apr 2025 13:17:13 +0000 Subject: [PATCH 1/2] Bump ros-apartment from 2.11.0 to 3.2.0 Note we aren't updating concurrent-ruby (which Dependabot would have updated) due to an incompatibility with Rails 7.0. Bumps [ros-apartment](https://github.com/rails-on-services/apartment) from 2.11.0 to 3.2.0. - [Release notes](https://github.com/rails-on-services/apartment/releases) - [Changelog](https://github.com/rails-on-services/apartment/blob/development/legacy_CHANGELOG.md) - [Commits](https://github.com/rails-on-services/apartment/compare/2.11.0...v3.2.0) --- updated-dependencies: - dependency-name: ros-apartment dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Gemfile | 2 +- Gemfile.lock | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index 589d35fd4..3830f0e7b 100644 --- a/Gemfile +++ b/Gemfile @@ -48,7 +48,7 @@ gem "recipient_interceptor", "~> 0.3.3" gem "redcarpet", "~> 3.6.0" gem "responders", "~> 3.1.1" gem "rinku", "~> 2.0.6", require: "rails_rinku" -gem "ros-apartment", "~> 2.11.0", require: "apartment" # Remove ConnectionHandling monkey patch when upgrading +gem "ros-apartment", "~> 3.2.0", require: "apartment" # Remove ConnectionHandling monkey patch when upgrading gem "sassc-embedded", "~> 1.77.5" gem "sassc-rails", "~> 2.1.2" gem "savon", "~> 2.15.1" diff --git a/Gemfile.lock b/Gemfile.lock index 5827996d9..531285ef8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -362,7 +362,7 @@ GEM mini_magick (4.13.2) mini_mime (1.1.5) mini_portile2 (2.8.8) - minitest (5.25.4) + minitest (5.25.5) mixlib-cli (2.1.8) mixlib-config (3.0.27) tomlrb @@ -470,7 +470,7 @@ GEM rugged (>= 0.24, < 2.0) psych (5.1.2) stringio - public_suffix (4.0.7) + public_suffix (6.0.1) puma (5.6.9) nio4r (~> 2.0) racc (1.8.1) @@ -533,11 +533,12 @@ GEM railties (>= 5.2) rexml (3.4.1) rinku (2.0.6) - ros-apartment (2.11.0) - activerecord (>= 5.0.0, < 7.1) + ros-apartment (3.2.0) + activerecord (>= 6.1.0, < 8.1) + activesupport (>= 6.1.0, < 8.1) parallel (< 2.0) - public_suffix (>= 2.0.5, < 5.0) - rack (>= 1.3.6, < 3.0) + public_suffix (>= 2.0.5, <= 6.0.1) + rack (>= 1.3.6, < 4.0) rspec-core (3.13.3) rspec-support (~> 3.13.0) rspec-expectations (3.13.3) @@ -787,7 +788,7 @@ DEPENDENCIES redcarpet (~> 3.6.0) responders (~> 3.1.1) rinku (~> 2.0.6) - ros-apartment (~> 2.11.0) + ros-apartment (~> 3.2.0) rspec-rails (~> 7.1.1) rubocop (~> 1.71.2) rubocop-capybara (~> 2.21.0) From b07e42935619bdf84686ff5a457ead9da760c610 Mon Sep 17 00:00:00 2001 From: taitus Date: Fri, 11 Apr 2025 15:39:33 +0200 Subject: [PATCH 2/2] Remove monkey patch for connected_to in Rails 7 ros-apartment 3.0.0+ includes official support for connection handling in Rails 7, so we no longer need to override `ActiveRecord::ConnectionHandling#connected_to`. References: PR #194 and #243 in ros-apartment --- Gemfile | 2 +- config/initializers/apartment.rb | 17 ----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/Gemfile b/Gemfile index 3830f0e7b..440a06319 100644 --- a/Gemfile +++ b/Gemfile @@ -48,7 +48,7 @@ gem "recipient_interceptor", "~> 0.3.3" gem "redcarpet", "~> 3.6.0" gem "responders", "~> 3.1.1" gem "rinku", "~> 2.0.6", require: "rails_rinku" -gem "ros-apartment", "~> 3.2.0", require: "apartment" # Remove ConnectionHandling monkey patch when upgrading +gem "ros-apartment", "~> 3.2.0", require: "apartment" gem "sassc-embedded", "~> 1.77.5" gem "sassc-rails", "~> 2.1.2" gem "savon", "~> 2.15.1" diff --git a/config/initializers/apartment.rb b/config/initializers/apartment.rb index e5d0a5110..cda7ae581 100644 --- a/config/initializers/apartment.rb +++ b/config/initializers/apartment.rb @@ -1,20 +1,3 @@ -module ActiveRecord # TODO: Remove after upgrading ros-apartment - # Code based on the current (as of March 2024) development version of the apartment gem - module ConnectionHandling - def connected_to_with_rails7_tenant(role: nil, prevent_writes: false, &blk) - current_tenant = Apartment::Tenant.current - - # The connected_to_without_tenant method is defined by Apartment - connected_to_without_tenant(role: role, prevent_writes: prevent_writes) do - Apartment::Tenant.switch!(current_tenant) - yield(blk) - end - end - - alias connected_to connected_to_with_rails7_tenant - end -end - # You can have Apartment route to the appropriate Tenant by adding some Rack middleware. # Apartment can support many different "Elevators" that can take care of this routing to your data. # Require whichever Elevator you're using below or none if you have a custom one.