Skip to content

Commit

Permalink
MONGOID-5818 Rails 8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
comandeo-mongo committed Nov 6, 2024
1 parent 1e4507b commit 2aabbc2
Show file tree
Hide file tree
Showing 19 changed files with 216 additions and 76 deletions.
80 changes: 61 additions & 19 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ functions:
"upload test results":
- command: attach.xunit_results
params:
file: ./src/tmp/rspec.xml
file: ./src/rspec.xml

"run tests":
- command: shell.exec
Expand Down Expand Up @@ -308,7 +308,7 @@ post:
# Removed, causing timeouts
# - func: "upload working dir"
- func: "upload mo artifacts"
#- func: "upload test results"
# - func: "upload test results"
- func: "upload test results to s3"

task_groups:
Expand Down Expand Up @@ -595,6 +595,10 @@ axes:
display_name: "Rails 7.2"
variables:
RAILS: "7.2"
- id: "8.0"
display_name: "Rails 8.0"
variables:
RAILS: "8.0.0.rc2"

- id: "test-i18n-fallbacks"
display_name: Test i18n fallbacks
Expand Down Expand Up @@ -734,19 +738,6 @@ buildvariants:
tasks:
- name: "test"

- matrix_name: "rails-7"
matrix_spec:
ruby: ["ruby-3.3"]
driver: ["current"]
mongodb-version: "6.0"
topology: "standalone"
rails: ['7.0', '7.1', '7.2']
os: ubuntu-22.04
fle: helper
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
tasks:
- name: "test"

- matrix_name: "bson-min"
matrix_spec:
driver: [bson-min]
Expand All @@ -769,6 +760,44 @@ buildvariants:
tasks:
- name: "test"

- matrix_name: "rails-master"
matrix_spec:
ruby: ["ruby-3.2"]
driver: ["current"]
mongodb-version: "7.0"
topology: "standalone"
rails: ['master']
os: ubuntu-22.04
fle: helper
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
tasks:
- name: "test"

- matrix_name: "rails-8"
matrix_spec:
ruby: ["ruby-3.3"]
driver: ["current"]
mongodb-version: "7.0"
topology: "standalone"
rails: ['8.0']
os: ubuntu-22.04
fle: helper
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
tasks:
- name: "test"

- matrix_name: "rails-7"
matrix_spec:
ruby: ["ruby-3.3"]
driver: ["current"]
mongodb-version: "6.0"
topology: "standalone"
rails: ['7.0', '7.1', '7.2']
os: ubuntu-22.04
fle: helper
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
tasks:
- name: "test"

- matrix_name: "rails-6"
matrix_spec:
Expand All @@ -794,27 +823,40 @@ buildvariants:
tasks:
- name: "test"

- matrix_name: app-tests-rails-8
matrix_spec:
ruby: ["ruby-3.2", "ruby-3.3"]
driver: ["current"]
mongodb-version: '7.0'
topology: standalone
app-tests: yes
rails: ['8.0']
os: ubuntu-22.04
display_name: "app tests ${driver}, ${ruby}, ${rails}"
tasks:
- name: "test"

- matrix_name: app-tests-rails-7
matrix_spec:
ruby: ["ruby-3.1", "ruby-3.2", "ruby-3.3"]
ruby: ["ruby-3.2", "ruby-3.3"]
driver: ["current"]
mongodb-version: '7.0'
topology: standalone
app-tests: yes
rails: ['6.1', '7.0', '7.1', '7.2']
rails: ['7.0', '7.1', '7.2']
os: ubuntu-22.04
display_name: "app tests ${driver}, ${ruby}, ${rails}"
tasks:
- name: "test"

- matrix_name: app-tests-rails-6-0
- matrix_name: app-tests-rails-6
matrix_spec:
ruby: ["ruby-3.0"]
driver: ["current"]
mongodb-version: '5.0'
topology: standalone
app-tests: yes
rails: ['6.0']
rails: ['6.0', '6.1']
os: ubuntu-20.04
display_name: "app tests ${driver}, ${ruby}, ${rails}"
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 @@ -222,6 +222,10 @@ axes:
display_name: "Rails 7.2"
variables:
RAILS: "7.2"
- id: "8.0"
display_name: "Rails 8.0"
variables:
RAILS: "8.0.0.rc2"

- id: "test-i18n-fallbacks"
display_name: Test i18n fallbacks
Expand Down
4 changes: 2 additions & 2 deletions .evergreen/config/commands.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ functions:
"upload test results":
- command: attach.xunit_results
params:
file: ./src/tmp/rspec.xml
file: ./src/rspec.xml

"run tests":
- command: shell.exec
Expand Down Expand Up @@ -282,7 +282,7 @@ post:
# Removed, causing timeouts
# - func: "upload working dir"
- func: "upload mo artifacts"
#- func: "upload test results"
# - func: "upload test results"
- func: "upload test results to s3"

task_groups:
Expand Down
72 changes: 55 additions & 17 deletions .evergreen/config/variants.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,6 @@ buildvariants:
tasks:
- name: "test"

- matrix_name: "rails-7"
matrix_spec:
ruby: ["ruby-3.3"]
driver: ["current"]
mongodb-version: "6.0"
topology: "standalone"
rails: ['7.0', '7.1', '7.2']
os: ubuntu-22.04
fle: helper
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
tasks:
- name: "test"

- matrix_name: "bson-min"
matrix_spec:
driver: [bson-min]
Expand All @@ -144,6 +131,44 @@ buildvariants:
tasks:
- name: "test"

- matrix_name: "rails-master"
matrix_spec:
ruby: ["ruby-3.2"]
driver: ["current"]
mongodb-version: "7.0"
topology: "standalone"
rails: ['master']
os: ubuntu-22.04
fle: helper
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
tasks:
- name: "test"

- matrix_name: "rails-8"
matrix_spec:
ruby: ["ruby-3.3"]
driver: ["current"]
mongodb-version: "7.0"
topology: "standalone"
rails: ['8.0']
os: ubuntu-22.04
fle: helper
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
tasks:
- name: "test"

- matrix_name: "rails-7"
matrix_spec:
ruby: ["ruby-3.3"]
driver: ["current"]
mongodb-version: "6.0"
topology: "standalone"
rails: ['7.0', '7.1', '7.2']
os: ubuntu-22.04
fle: helper
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
tasks:
- name: "test"

- matrix_name: "rails-6"
matrix_spec:
Expand All @@ -169,27 +194,40 @@ buildvariants:
tasks:
- name: "test"

- matrix_name: app-tests-rails-8
matrix_spec:
ruby: ["ruby-3.2", "ruby-3.3"]
driver: ["current"]
mongodb-version: '7.0'
topology: standalone
app-tests: yes
rails: ['8.0']
os: ubuntu-22.04
display_name: "app tests ${driver}, ${ruby}, ${rails}"
tasks:
- name: "test"

- matrix_name: app-tests-rails-7
matrix_spec:
ruby: ["ruby-3.1", "ruby-3.2", "ruby-3.3"]
ruby: ["ruby-3.2", "ruby-3.3"]
driver: ["current"]
mongodb-version: '7.0'
topology: standalone
app-tests: yes
rails: ['6.1', '7.0', '7.1', '7.2']
rails: ['7.0', '7.1', '7.2']
os: ubuntu-22.04
display_name: "app tests ${driver}, ${ruby}, ${rails}"
tasks:
- name: "test"

- matrix_name: app-tests-rails-6-0
- matrix_name: app-tests-rails-6
matrix_spec:
ruby: ["ruby-3.0"]
driver: ["current"]
mongodb-version: '5.0'
topology: standalone
app-tests: yes
rails: ['6.0']
rails: ['6.0', '6.1']
os: ubuntu-20.04
display_name: "app tests ${driver}, ${ruby}, ${rails}"
tasks:
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ if test -f tmp/rspec-all.json; then
mv tmp/rspec-all.json tmp/rspec.json
fi

python3 -m mtools.mlaunch.mlaunch stop --dir "$dbdir"
python3 -m mtools.mlaunch.mlaunch stop --dir "$dbdir" || true

exit ${test_status}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ examples
.env
.env.private*
build
rspec.xml
4 changes: 4 additions & 0 deletions gemfiles/rails-6.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ source 'https://rubygems.org'
gem 'actionpack', '~> 6.0'
gem 'activemodel', '~> 6.0'

group :test do
gem 'activejob', '~> 6.0'
end

gemspec path: '..'

require_relative './standard'
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/rails-6.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ source 'https://rubygems.org'
gem 'actionpack', '~> 6.1'
gem 'activemodel', '~> 6.1'

group :test do
gem 'activejob', '~> 6.1'
end
gemspec path: '..'

require_relative './standard'
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/rails-7.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ source 'https://rubygems.org'
gem 'actionpack', '~> 7.0'
gem 'activemodel', '~> 7.0'

group :test do
gem 'activejob', '~> 7.0'
end
gemspec path: '..'

require_relative './standard'
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/rails-7.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ source 'https://rubygems.org'
gem 'actionpack', '~> 7.1'
gem 'activemodel', '~> 7.1'

group :test do
gem 'activejob', '~> 7.1'
end
gemspec path: '..'

require_relative './standard'
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/rails-7.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ source 'https://rubygems.org'
gem 'actionpack', '~> 7.2'
gem 'activemodel', '~> 7.2'

group :test do
gem 'activejob', '~> 7.2'
end
gemspec path: '..'

require_relative './standard'
Expand Down
14 changes: 14 additions & 0 deletions gemfiles/rails-8.0.0.rc2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# rubocop:todo all
source 'https://rubygems.org'

gem 'actionpack', '8.0.0.rc2'
gem 'activemodel', '8.0.0.rc2'

group :test do
gem 'activejob', '8.0.0.rc2'
end
gemspec path: '..'

require_relative './standard'

standard_dependencies
4 changes: 4 additions & 0 deletions gemfiles/rails-master.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ source 'https://rubygems.org'
gem 'actionpack', git: 'https://github.com/rails/rails'
gem 'activemodel', git: 'https://github.com/rails/rails'

group :test do
gem 'activejob', git: 'https://github.com/rails/rails'
end

gemspec path: '..'

require_relative './standard'
Expand Down
1 change: 0 additions & 1 deletion gemfiles/standard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def standard_dependencies
end

group :test do
gem 'activejob'
gem 'timecop'
gem 'rspec-retry'
gem 'benchmark-ips'
Expand Down
8 changes: 6 additions & 2 deletions lib/mongoid/traversable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ def discriminator_key=(value)
if value
Mongoid::Fields::Validators::Macro.validate_field_name(self, value)
value = value.to_s
super
if defined?(::ActiveSupport::ClassAttribute)
::ActiveSupport::ClassAttribute.redefine(self, 'discriminator_key', value)
else
super
end
else
# When discriminator key is set to nil, replace the class's definition
# of the discriminator key reader (provided by class_attribute earlier)
Expand All @@ -119,7 +123,7 @@ class << self
# an existing field.
# This condition also checks if the class has any descendants, because
# if it doesn't then it doesn't need a discriminator key.
return unless !fields.key?(discriminator_key) && !descendants.empty?
return if fields.key?(discriminator_key) || descendants.empty?

default_proc = -> { self.class.discriminator_value }
field(discriminator_key, default: default_proc, type: String)
Expand Down
Loading

0 comments on commit 2aabbc2

Please sign in to comment.