Skip to content

Commit 4f1e49c

Browse files
Run tests on Rails 8
1 parent 27ee7ec commit 4f1e49c

File tree

6 files changed

+111
-43
lines changed

6 files changed

+111
-43
lines changed

.evergreen/config.yml

+49-19
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ functions:
259259
"upload test results":
260260
- command: attach.xunit_results
261261
params:
262-
file: ./src/tmp/rspec.xml
262+
file: ./src/rspec.xml
263263

264264
"run tests":
265265
- command: shell.exec
@@ -308,7 +308,7 @@ post:
308308
# Removed, causing timeouts
309309
# - func: "upload working dir"
310310
- func: "upload mo artifacts"
311-
#- func: "upload test results"
311+
# - func: "upload test results"
312312
- func: "upload test results to s3"
313313

314314
task_groups:
@@ -595,6 +595,10 @@ axes:
595595
display_name: "Rails 7.2"
596596
variables:
597597
RAILS: "7.2"
598+
- id: "8.0"
599+
display_name: "Rails 8.0"
600+
variables:
601+
RAILS: "8.0.0.rc2"
598602

599603
- id: "test-i18n-fallbacks"
600604
display_name: Test i18n fallbacks
@@ -734,19 +738,6 @@ buildvariants:
734738
tasks:
735739
- name: "test"
736740

737-
- matrix_name: "rails-7"
738-
matrix_spec:
739-
ruby: ["ruby-3.3"]
740-
driver: ["current"]
741-
mongodb-version: "6.0"
742-
topology: "standalone"
743-
rails: ['7.0', '7.1', '7.2']
744-
os: ubuntu-22.04
745-
fle: helper
746-
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
747-
tasks:
748-
- name: "test"
749-
750741
- matrix_name: "bson-min"
751742
matrix_spec:
752743
driver: [bson-min]
@@ -769,6 +760,31 @@ buildvariants:
769760
tasks:
770761
- name: "test"
771762

763+
- matrix_name: "rails-8"
764+
matrix_spec:
765+
ruby: ["ruby-3.3"]
766+
driver: ["current"]
767+
mongodb-version: "7.0"
768+
topology: "standalone"
769+
rails: ['8.0']
770+
os: ubuntu-22.04
771+
fle: helper
772+
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
773+
tasks:
774+
- name: "test"
775+
776+
- matrix_name: "rails-7"
777+
matrix_spec:
778+
ruby: ["ruby-3.3"]
779+
driver: ["current"]
780+
mongodb-version: "6.0"
781+
topology: "standalone"
782+
rails: ['7.0', '7.1', '7.2']
783+
os: ubuntu-22.04
784+
fle: helper
785+
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
786+
tasks:
787+
- name: "test"
772788

773789
- matrix_name: "rails-6"
774790
matrix_spec:
@@ -794,27 +810,41 @@ buildvariants:
794810
tasks:
795811
- name: "test"
796812

813+
- matrix_name: app-tests-rails-8
814+
matrix_spec:
815+
ruby: ["ruby-3.2", "ruby-3.3"]
816+
driver: ["current"]
817+
mongodb-version: '7.0'
818+
topology: standalone
819+
app-tests: yes
820+
rails: ['8.0']
821+
os: ubuntu-22.04
822+
display_name: "app tests ${driver}, ${ruby}, ${rails}"
823+
tasks:
824+
- name: "test"
825+
826+
797827
- matrix_name: app-tests-rails-7
798828
matrix_spec:
799-
ruby: ["ruby-3.1", "ruby-3.2", "ruby-3.3"]
829+
ruby: ["ruby-3.2", "ruby-3.3"]
800830
driver: ["current"]
801831
mongodb-version: '7.0'
802832
topology: standalone
803833
app-tests: yes
804-
rails: ['6.1', '7.0', '7.1', '7.2']
834+
rails: ['7.0', '7.1', '7.2']
805835
os: ubuntu-22.04
806836
display_name: "app tests ${driver}, ${ruby}, ${rails}"
807837
tasks:
808838
- name: "test"
809839

810-
- matrix_name: app-tests-rails-6-0
840+
- matrix_name: app-tests-rails-6
811841
matrix_spec:
812842
ruby: ["ruby-3.0"]
813843
driver: ["current"]
814844
mongodb-version: '5.0'
815845
topology: standalone
816846
app-tests: yes
817-
rails: ['6.0']
847+
rails: ['6.0', '6.1']
818848
os: ubuntu-20.04
819849
display_name: "app tests ${driver}, ${ruby}, ${rails}"
820850
tasks:

.evergreen/config/axes.yml.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ axes:
225225
- id: "8.0"
226226
display_name: "Rails 8.0"
227227
variables:
228-
RAILS: "8.0"
228+
RAILS: "8.0.0.rc2"
229229

230230
- id: "test-i18n-fallbacks"
231231
display_name: Test i18n fallbacks

.evergreen/config/variants.yml.erb

+43-17
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,6 @@ buildvariants:
109109
tasks:
110110
- name: "test"
111111

112-
- matrix_name: "rails-7"
113-
matrix_spec:
114-
ruby: ["ruby-3.3"]
115-
driver: ["current"]
116-
mongodb-version: "6.0"
117-
topology: "standalone"
118-
rails: ['7.0', '7.1', '7.2']
119-
os: ubuntu-22.04
120-
fle: helper
121-
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
122-
tasks:
123-
- name: "test"
124-
125112
- matrix_name: "bson-min"
126113
matrix_spec:
127114
driver: [bson-min]
@@ -144,6 +131,31 @@ buildvariants:
144131
tasks:
145132
- name: "test"
146133

134+
- matrix_name: "rails-8"
135+
matrix_spec:
136+
ruby: ["ruby-3.3"]
137+
driver: ["current"]
138+
mongodb-version: "7.0"
139+
topology: "standalone"
140+
rails: ['8.0']
141+
os: ubuntu-22.04
142+
fle: helper
143+
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
144+
tasks:
145+
- name: "test"
146+
147+
- matrix_name: "rails-7"
148+
matrix_spec:
149+
ruby: ["ruby-3.3"]
150+
driver: ["current"]
151+
mongodb-version: "6.0"
152+
topology: "standalone"
153+
rails: ['7.0', '7.1', '7.2']
154+
os: ubuntu-22.04
155+
fle: helper
156+
display_name: "${rails}, ${driver}, ${mongodb-version} (FLE ${fle})"
157+
tasks:
158+
- name: "test"
147159

148160
- matrix_name: "rails-6"
149161
matrix_spec:
@@ -169,27 +181,41 @@ buildvariants:
169181
tasks:
170182
- name: "test"
171183

184+
- matrix_name: app-tests-rails-8
185+
matrix_spec:
186+
ruby: ["ruby-3.2", "ruby-3.3"]
187+
driver: ["current"]
188+
mongodb-version: '7.0'
189+
topology: standalone
190+
app-tests: yes
191+
rails: ['8.0']
192+
os: ubuntu-22.04
193+
display_name: "app tests ${driver}, ${ruby}, ${rails}"
194+
tasks:
195+
- name: "test"
196+
197+
172198
- matrix_name: app-tests-rails-7
173199
matrix_spec:
174-
ruby: ["ruby-3.1", "ruby-3.2", "ruby-3.3"]
200+
ruby: ["ruby-3.2", "ruby-3.3"]
175201
driver: ["current"]
176202
mongodb-version: '7.0'
177203
topology: standalone
178204
app-tests: yes
179-
rails: ['6.1', '7.0', '7.1', '7.2']
205+
rails: ['7.0', '7.1', '7.2']
180206
os: ubuntu-22.04
181207
display_name: "app tests ${driver}, ${ruby}, ${rails}"
182208
tasks:
183209
- name: "test"
184210

185-
- matrix_name: app-tests-rails-6-0
211+
- matrix_name: app-tests-rails-6
186212
matrix_spec:
187213
ruby: ["ruby-3.0"]
188214
driver: ["current"]
189215
mongodb-version: '5.0'
190216
topology: standalone
191217
app-tests: yes
192-
rails: ['6.0']
218+
rails: ['6.0', '6.1']
193219
os: ubuntu-20.04
194220
display_name: "app tests ${driver}, ${ruby}, ${rails}"
195221
tasks:

gemfiles/rails-8.0.gemfile gemfiles/rails-8.0.0.rc2.gemfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# rubocop:todo all
22
source 'https://rubygems.org'
33

4-
gem 'actionpack', '8.0.0.beta1'
5-
gem 'activemodel', '8.0.0.beta1'
4+
gem 'actionpack', '8.0.0.rc2'
5+
gem 'activemodel', '8.0.0.rc2'
66

77
group :test do
8-
gem 'activejob', '8.0.0.beta1'
8+
gem 'activejob', '8.0.0.rc2'
99
end
1010
gemspec path: '..'
1111

lib/mongoid/traversable.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ def discriminator_key=(value)
105105
if value
106106
Mongoid::Fields::Validators::Macro.validate_field_name(self, value)
107107
value = value.to_s
108-
super
108+
if defined?(::ActiveSupport::ClassAttribute)
109+
::ActiveSupport::ClassAttribute.redefine(self, 'discriminator_key', value)
110+
else
111+
super
112+
end
109113
else
110114
# When discriminator key is set to nil, replace the class's definition
111115
# of the discriminator key reader (provided by class_attribute earlier)
@@ -119,7 +123,7 @@ class << self
119123
# an existing field.
120124
# This condition also checks if the class has any descendants, because
121125
# if it doesn't then it doesn't need a discriminator key.
122-
return unless !fields.key?(discriminator_key) && !descendants.empty?
126+
return if fields.key?(discriminator_key) || descendants.empty?
123127

124128
default_proc = -> { self.class.discriminator_value }
125129
field(discriminator_key, default: default_proc, type: String)

spec/integration/app_spec.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def insert_rails_gem_version(cmd)
3636
context 'demo application' do
3737
context 'sinatra' do
3838
it 'runs' do
39+
skip 'https://jira.mongodb.org/browse/MONGOID-5826'
40+
3941
clone_application(
4042
'https://github.com/mongoid/mongoid-demo',
4143
subdir: 'sinatra-minimal',
@@ -55,6 +57,8 @@ def insert_rails_gem_version(cmd)
5557

5658
context 'rails-api' do
5759
it 'runs' do
60+
skip 'https://jira.mongodb.org/browse/MONGOID-5826'
61+
5862
clone_application(
5963
'https://github.com/mongoid/mongoid-demo',
6064
subdir: 'rails-api',
@@ -172,7 +176,7 @@ def install_rails
172176
if (rails_version = SpecConfig.instance.rails_version) == 'master'
173177
else
174178
check_call(%w(gem list))
175-
check_call(%w(gem install rails --no-document -v) + ["~> #{rails_version}.0"])
179+
check_call(%w(gem install rails --no-document --force -v) + ["~> #{rails_version}.0"])
176180
end
177181
end
178182

@@ -319,6 +323,10 @@ def adjust_app_gemfile(rails_version: SpecConfig.instance.rails_version)
319323
end
320324

321325
def adjust_rails_defaults(rails_version: SpecConfig.instance.rails_version)
326+
if !rails_version.match?(/^\d+\.\d+$/)
327+
# This must be pre-release version, we trim it
328+
rails_version = rails_version.split('.')[0..1].join('.')
329+
end
322330
if File.exist?('config/application.rb')
323331
lines = IO.readlines('config/application.rb')
324332
lines.each do |line|

0 commit comments

Comments
 (0)