Skip to content

Commit

Permalink
MONGOID-5689 Add Rails 7.1 support (#5728) (#5729)
Browse files Browse the repository at this point in the history
  • Loading branch information
comandeo-mongo authored Oct 10, 2023
1 parent d919bb1 commit c12a285
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 23 deletions.
23 changes: 15 additions & 8 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ functions:
DRIVER="${DRIVER}" \
I18N="${I18N}" \
TEST_I18N_FALLBACKS="${TEST_I18N_FALLBACKS}" \
.evergreen/run-tests.sh
FLE="${FLE}" \
APP_TESTS="${APP_TESTS}" \
.evergreen/run-tests-docker.sh
"fix absolute paths":
- command: shell.exec
Expand Down Expand Up @@ -444,17 +446,17 @@ axes:
values:
- id: ubuntu-22.04
display_name: "Ubuntu 22.04"
run_on: ubuntu2204-small
run_on: ubuntu2004-small
variables:
DOCKER_DISTRO: ubuntu2204
- id: debian11
display_name: "Debian 11"
run_on: debian11-small
run_on: ubuntu2004-small
variables:
DOCKER_DISTRO: debian11
- id: rhel80
display_name: "RHEL 8.0"
run_on: rhel80-small
run_on: ubuntu2004-small
variables:
DOCKER_DISTRO: rhel80

Expand Down Expand Up @@ -529,6 +531,10 @@ axes:
display_name: "Rails 7.0"
variables:
RAILS: "7.0"
- id: "7.1"
display_name: "Rails 7.1"
variables:
RAILS: "7.1"

- id: "i18n"
display_name: I18n version
Expand Down Expand Up @@ -684,9 +690,10 @@ buildvariants:
driver: ["current"]
mongodb-version: "6.0"
topology: "standalone"
rails: ['7.0']
os: debian11
display_name: "${rails}, ${driver}, ${mongodb-version}"
rails: ['7.0', '7.1']
os: ubuntu-22.04
fle: helper
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
tasks:
- name: "test"

Expand Down Expand Up @@ -769,7 +776,7 @@ buildvariants:
mongodb-version: '6.0'
topology: standalone
app-tests: yes
rails: ['6.0', '6.1', '7.0']
rails: ['6.0', '6.1', '7.0', '7.1']
os: rhel80
display_name: "app tests ${driver}, ${ruby}, ${rails}"
tasks:
Expand Down
10 changes: 7 additions & 3 deletions .evergreen/config/axes.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,17 @@ axes:
values:
- id: ubuntu-22.04
display_name: "Ubuntu 22.04"
run_on: ubuntu2204-small
run_on: ubuntu2004-small
variables:
DOCKER_DISTRO: ubuntu2204
- id: debian11
display_name: "Debian 11"
run_on: debian11-small
run_on: ubuntu2004-small
variables:
DOCKER_DISTRO: debian11
- id: rhel80
display_name: "RHEL 8.0"
run_on: rhel80-small
run_on: ubuntu2004-small
variables:
DOCKER_DISTRO: rhel80

Expand Down Expand Up @@ -206,6 +206,10 @@ axes:
display_name: "Rails 7.0"
variables:
RAILS: "7.0"
- id: "7.1"
display_name: "Rails 7.1"
variables:
RAILS: "7.1"

- id: "i18n"
display_name: I18n version
Expand Down
4 changes: 3 additions & 1 deletion .evergreen/config/commands.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,9 @@ functions:
DRIVER="${DRIVER}" \
I18N="${I18N}" \
TEST_I18N_FALLBACKS="${TEST_I18N_FALLBACKS}" \
.evergreen/run-tests.sh
FLE="${FLE}" \
APP_TESTS="${APP_TESTS}" \
.evergreen/run-tests-docker.sh

"fix absolute paths":
- command: shell.exec
Expand Down
9 changes: 5 additions & 4 deletions .evergreen/config/variants.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ buildvariants:
driver: ["current"]
mongodb-version: "6.0"
topology: "standalone"
rails: ['7.0']
os: debian11
display_name: "${rails}, ${driver}, ${mongodb-version}"
rails: ['7.0', '7.1']
os: ubuntu-22.04
fle: helper
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
tasks:
- name: "test"

Expand Down Expand Up @@ -200,7 +201,7 @@ buildvariants:
mongodb-version: '6.0'
topology: standalone
app-tests: yes
rails: ['6.0', '6.1', '7.0']
rails: ['6.0', '6.1', '7.0', '7.1']
os: rhel80
display_name: "app tests ${driver}, ${ruby}, ${rails}"
tasks:
Expand Down
13 changes: 13 additions & 0 deletions docs/reference/compatibility.txt
Original file line number Diff line number Diff line change
Expand Up @@ -399,62 +399,71 @@ are supported by Mongoid.
:class: compatibility-large no-padding

* - Mongoid
- Rails 7.1
- Rails 7.0
- Rails 6.1
- Rails 6.0
- Rails 5.2
- Rails 5.1

* - 8.1
- |checkmark| [#rails-7.1]_
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark| [#rails-5-ruby-3.0]_
-

* - 8.0
- |checkmark| [#rails-7.1]_
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark| [#rails-5-ruby-3.0]_
-

* - 7.5
-
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark| [#rails-5-ruby-3.0]_
- D

* - 7.4
-
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark| [#rails-5-ruby-3.0]_
- |checkmark| [#rails-5-ruby-3.0]_

* - 7.3
-
- |checkmark| [#rails-7-Mongoid-7.3]_
- |checkmark|
- |checkmark|
- |checkmark| [#rails-5-ruby-3.0]_
- |checkmark| [#rails-5-ruby-3.0]_

* - 7.2
-
-
- |checkmark| [#rails-6.1]_
- |checkmark|
- |checkmark| [#rails-5-ruby-3.0]_
- |checkmark| [#rails-5-ruby-3.0]_

* - 7.1
-
-
- |checkmark| [#rails-6.1]_
- |checkmark|
- |checkmark|
- |checkmark|

* - 7.0
-
-
- |checkmark| [#rails-6.1]_
- |checkmark| [#rails-6]_
Expand All @@ -465,6 +474,7 @@ are supported by Mongoid.
-
-
-
-
- |checkmark|
- |checkmark|

Expand All @@ -477,4 +487,7 @@ are supported by Mongoid.

.. [#rails-7-Mongoid-7.3] Rails 7.x requires Mongoid 7.3.4 or later.

.. [#rails-7.1] Rails 7.1 requires Mongoid 8.0.7 or 8.1.3 in the respective
8.0 and 8.1 stable branches.

.. include:: /includes/unicode-checkmark.rst
10 changes: 10 additions & 0 deletions gemfiles/rails-7.1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
source 'https://rubygems.org'

gem 'actionpack', '~> 7.1'
gem 'activemodel', '~> 7.1'

gemspec path: '..'

require_relative './standard'

standard_dependencies
3 changes: 2 additions & 1 deletion lib/mongoid/deprecable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ module Deprecable
# @param [ [ Symbol | Hash<Symbol, [ Symbol | String ]> ]... ] *method_descriptors
# The methods to deprecate, with optional replacement instructions.
def deprecate(target_module, *method_descriptors)
Mongoid::Deprecation.deprecate_methods(target_module, *method_descriptors)
@_deprecator ||= Mongoid::Deprecation.new
@_deprecator.deprecate_methods(target_module, *method_descriptors)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/mongoid/deprecation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class Deprecation < ::ActiveSupport::Deprecation
#
# @return Array<Proc> The deprecation behavior.
def behavior
@behavior ||= Array(->(message, callstack, _deprecation_horizon, _gem_name) {
@behavior ||= Array(->(*args) {
logger = Mongoid.logger
logger.warn(message)
logger.debug(callstack.join("\n ")) if debug
logger.warn(args[0])
logger.debug(args[1].join("\n ")) if debug
})
end
end
Expand Down
8 changes: 7 additions & 1 deletion lib/mongoid/interceptable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,13 @@ def run_targeted_callbacks(place, kind)
end
self.class.send :define_method, name do
env = ActiveSupport::Callbacks::Filters::Environment.new(self, false, nil)
sequence = chain.compile
sequence = if chain.method(:compile).arity == 0
# ActiveSupport < 7.1
chain.compile
else
# ActiveSupport >= 7.1
chain.compile(nil)
end
sequence.invoke_before(env)
env.value = !env.halted
sequence.invoke_after(env)
Expand Down
2 changes: 1 addition & 1 deletion mongoid.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Gem::Specification.new do |s|
# Ruby 3.0 requires ActiveModel 6.0 or higher.
# activemodel 7.0.0 cannot be used due to Class#descendants issue
# See: https://github.com/rails/rails/pull/43951
s.add_dependency("activemodel", ['>=5.1', '<7.1', '!= 7.0.0'])
s.add_dependency("activemodel", ['>=5.1', '<7.2', '!= 7.0.0'])
s.add_dependency("mongo", ['>=2.18.0', '<3.0.0'])
s.add_dependency("concurrent-ruby", ['>= 1.0.5', '< 2.0'])

Expand Down
2 changes: 1 addition & 1 deletion spec/shared

0 comments on commit c12a285

Please sign in to comment.