Skip to content

Commit

Permalink
MONGOID-5689 Add Rails 7.1 support (mongodb#5728)
Browse files Browse the repository at this point in the history
* MONGOID-5689 Add Rails 7.1 support

* Fix 7.1 incompatibilities

* Update docs
  • Loading branch information
comandeo-mongo committed Oct 9, 2023
1 parent ce49093 commit 1e2f618
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 9 deletions.
6 changes: 5 additions & 1 deletion .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,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 @@ -659,7 +663,7 @@ buildvariants:
driver: ["current"]
mongodb-version: "5.0"
topology: "standalone"
rails: ['7.0']
rails: ['7.0', '7.1']
os: ubuntu-20.04
display_name: "${rails}, ${driver}, ${mongodb-version}"
tasks:
Expand Down
4 changes: 4 additions & 0 deletions .evergreen/config/axes.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,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
2 changes: 1 addition & 1 deletion .evergreen/config/variants.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ buildvariants:
driver: ["current"]
mongodb-version: "5.0"
topology: "standalone"
rails: ['7.0']
rails: ['7.0', '7.1']
os: ubuntu-20.04
display_name: "${rails}, ${driver}, ${mongodb-version}"
tasks:
Expand Down
31 changes: 30 additions & 1 deletion docs/reference/compatibility.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ specified Mongoid versions.
:class: compatibility-large no-padding

* - Mongoid
- Driver 2.18
- Driver 2.19-2.18
- Driver 2.17-2.10
- Driver 2.9-2.7

Expand Down Expand Up @@ -88,6 +88,7 @@ is deprecated.
:class: compatibility-large no-padding

* - Mongoid
- Ruby 3.2
- Ruby 3.1
- Ruby 3.0
- Ruby 2.7
Expand All @@ -100,6 +101,7 @@ is deprecated.
- JRuby 9.3

* - 8.0
-
- |checkmark|
- |checkmark|
- |checkmark|
Expand All @@ -112,6 +114,7 @@ is deprecated.
- |checkmark|

* - 7.5
-
- |checkmark|
- |checkmark|
- |checkmark|
Expand All @@ -124,6 +127,7 @@ is deprecated.
- |checkmark|

* - 7.4
-
- |checkmark|
- |checkmark|
- |checkmark|
Expand All @@ -136,6 +140,7 @@ is deprecated.
-

* - 7.3
-
- |checkmark| [#mongoid-7.3-ruby-3.0]_
- |checkmark| [#mongoid-7.3-ruby-3.0]_
- |checkmark|
Expand All @@ -148,6 +153,7 @@ is deprecated.
-

* - 7.2
-
- |checkmark| [#mongoid-7.2-ruby-3.0]_
- |checkmark| [#mongoid-7.2-ruby-3.0]_
- |checkmark|
Expand All @@ -160,6 +166,7 @@ is deprecated.
-

* - 7.1
-
- |checkmark| [#mongoid-7.1-ruby-3.0]_
- |checkmark| [#mongoid-7.1-ruby-3.0]_
- |checkmark|
Expand All @@ -172,6 +179,7 @@ is deprecated.
-

* - 7.0
-
-
-
- |checkmark|
Expand All @@ -187,6 +195,7 @@ is deprecated.
-
-
-
-
- |checkmark|
- |checkmark|
- |checkmark| [#ruby-2.4]_
Expand Down Expand Up @@ -227,6 +236,7 @@ and will be removed in a next version.
:class: compatibility-large no-padding

* - Mongoid
- MongoDB 7.0
- MongoDB 6.0
- MongoDB 5.0
- MongoDB 4.4
Expand All @@ -245,6 +255,7 @@ and will be removed in a next version.
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
-
-
-
Expand All @@ -257,6 +268,7 @@ and will be removed in a next version.
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
- D
- D
- D
Expand All @@ -269,12 +281,14 @@ and will be removed in a next version.
- |checkmark|
- |checkmark|
- |checkmark|
- |checkmark|
- D
- D
- D
- D

* - 7.3
-
-
- |checkmark|
- |checkmark|
Expand All @@ -287,6 +301,7 @@ and will be removed in a next version.
- D

* - 7.2
-
-
- |checkmark|
- |checkmark|
Expand All @@ -299,6 +314,7 @@ and will be removed in a next version.
- D

* - 7.1
-
-
- |checkmark|
- |checkmark|
Expand All @@ -311,6 +327,7 @@ and will be removed in a next version.
- D

* - 7.0
-
-
- |checkmark|
- |checkmark|
Expand All @@ -323,6 +340,7 @@ and will be removed in a next version.
- D

* - 6.4
-
-
- |checkmark|
- |checkmark|
Expand All @@ -349,55 +367,63 @@ 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.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 @@ -408,6 +434,7 @@ are supported by Mongoid.
-
-
-
-
- |checkmark|
- |checkmark|

Expand All @@ -420,4 +447,6 @@ 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.

.. 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 @@ -298,7 +298,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'])

# The ruby2_keywords gem is recommended for handling argument delegation issues,
Expand Down

0 comments on commit 1e2f618

Please sign in to comment.