Skip to content

Commit

Permalink
MONGOID-5716 Remove all tests/hacks related to use of I18n v1.0 (#5757)
Browse files Browse the repository at this point in the history
Co-authored-by: Dmitry Rybakov <[email protected]>
  • Loading branch information
johnnyshields and comandeo-mongo authored Nov 28, 2023
1 parent 1c77b9d commit 0cde1be
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 101 deletions.
25 changes: 0 additions & 25 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ functions:
export RVM_RUBY="${RVM_RUBY}"
export RAILS="${RAILS}"
export DRIVER="${DRIVER}"
export I18N="${I18N}"
export TEST_I18N_FALLBACKS="${TEST_I18N_FALLBACKS}"
export FLE="${FLE}"
EOT
Expand Down Expand Up @@ -276,7 +275,6 @@ functions:
RVM_RUBY="${RVM_RUBY}" \
RAILS="${RAILS}" \
DRIVER="${DRIVER}" \
I18N="${I18N}" \
TEST_I18N_FALLBACKS="${TEST_I18N_FALLBACKS}" \
FLE="${FLE}" \
.evergreen/run-tests-docker.sh
Expand Down Expand Up @@ -594,16 +592,6 @@ axes:
variables:
RAILS: "7.1"

- id: "i18n"
display_name: I18n version
values:
- id: '1.0'
display_name: "i18n-1.0"
variables:
I18N: "1.0"
- id: current
display_name: "i18n-current"

- id: "test-i18n-fallbacks"
display_name: Test i18n fallbacks
values:
Expand Down Expand Up @@ -802,25 +790,12 @@ buildvariants:
tasks:
- name: "test"

- matrix_name: "i18n-1.0"
matrix_spec:
ruby: "ruby-2.6"
driver: ["current"]
mongodb-version: "4.4"
topology: "standalone"
i18n: '1.0'
os: rhel80
display_name: "i18n-1.0 ${rails}, ${driver}, ${mongodb-version}"
tasks:
- name: "test"

- matrix_name: "i18n-fallbacks"
matrix_spec:
ruby: "ruby-2.6"
driver: ["current"]
mongodb-version: "4.2"
topology: "standalone"
i18n: '*'
test-i18n-fallbacks: yes
os: rhel80
display_name: "i18n fallbacks ${rails}, ${driver}, ${mongodb-version}, ${i18n}"
Expand Down
10 changes: 0 additions & 10 deletions .evergreen/config/axes.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,6 @@ axes:
variables:
RAILS: "7.1"

- id: "i18n"
display_name: I18n version
values:
- id: '1.0'
display_name: "i18n-1.0"
variables:
I18N: "1.0"
- id: current
display_name: "i18n-current"

- id: "test-i18n-fallbacks"
display_name: Test i18n fallbacks
values:
Expand Down
2 changes: 0 additions & 2 deletions .evergreen/config/commands.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ functions:
export RVM_RUBY="${RVM_RUBY}"
export RAILS="${RAILS}"
export DRIVER="${DRIVER}"
export I18N="${I18N}"
export TEST_I18N_FALLBACKS="${TEST_I18N_FALLBACKS}"
export FLE="${FLE}"
EOT
Expand Down Expand Up @@ -250,7 +249,6 @@ functions:
RVM_RUBY="${RVM_RUBY}" \
RAILS="${RAILS}" \
DRIVER="${DRIVER}" \
I18N="${I18N}" \
TEST_I18N_FALLBACKS="${TEST_I18N_FALLBACKS}" \
FLE="${FLE}" \
.evergreen/run-tests-docker.sh
Expand Down
4 changes: 1 addition & 3 deletions .evergreen/config/variants.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ buildvariants:
driver: ["current"]
mongodb-version: "4.4"
topology: "standalone"
i18n: '1.0'
os: rhel80
display_name: "i18n-1.0 ${rails}, ${driver}, ${mongodb-version}"
tasks:
Expand All @@ -187,10 +186,9 @@ buildvariants:
driver: ["current"]
mongodb-version: "4.2"
topology: "standalone"
i18n: '*'
test-i18n-fallbacks: yes
os: rhel80
display_name: "i18n fallbacks ${rails}, ${driver}, ${mongodb-version}, ${i18n}"
display_name: "i18n fallbacks ${rails}, ${driver}, ${mongodb-version}"
tasks:
- name: "test"

Expand Down
13 changes: 5 additions & 8 deletions .evergreen/make-github-actions
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ class EvergreenConfig < YamlConfig
# these will be later mapped to gemfile
driver: spec[:driver],
rails: spec[:rails],
i18n: spec[:i18n],
}

missing = node.map {|k, v| k if v.blank? }.compact
missing -= %i[driver rails i18n]
missing -= %i[driver rails]

if missing.present?
puts "Skipping invalid Evergreen buildvariant '#{name}'. Keys missing: #{missing}"
Expand Down Expand Up @@ -101,7 +100,7 @@ class GithubConfig < YamlConfig
end

class Transmogrifier
SPLATTABLE_FIELDS = %i[mongodb topology ruby rails driver i18n]
SPLATTABLE_FIELDS = %i[mongodb topology ruby rails driver]
COMPACTABLE_FIELDS = %i[mongodb topology ruby gemfile]

attr_reader :eg_config,
Expand Down Expand Up @@ -205,18 +204,16 @@ class Transmogrifier
end

def extract_gemfile!(node)
node[:gemfile] = get_gemfile(*node.values_at(:driver, :rails, :i18n))
node[:gemfile] = get_gemfile(*node.values_at(:driver, :rails))
end

# Ported from run-tests.sh
def get_gemfile(driver, rails, i18n)
driver, rails, i18n = [driver, rails, i18n].map {|v| v&.to_s }
def get_gemfile(driver, rails)
driver, rails = [driver, rails].map {|v| v&.to_s }
if driver && driver != 'current'
"gemfiles/driver_#{driver.underscore}.gemfile"
elsif rails && rails != '6.1' # TODO: "6.1" should be renamed to "current" in Evergreen
"gemfiles/rails-#{rails}.gemfile"
elsif i18n && i18n == '1.0'
'gemfiles/i18n-1.0.gemfile'
else
'Gemfile'
end
Expand Down
3 changes: 0 additions & 3 deletions .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ elif test "$RAILS" = "master-jruby"; then
elif test -n "$RAILS" && test "$RAILS" != 6.1; then
bundle install --gemfile=gemfiles/rails-"$RAILS".gemfile
BUNDLE_GEMFILE=gemfiles/rails-"$RAILS".gemfile
elif test "$I18N" = "1.0"; then
bundle install --gemfile=gemfiles/i18n-1.0.gemfile
BUNDLE_GEMFILE=gemfiles/i18n-1.0.gemfile
else
bundle install
fi
Expand Down
4 changes: 3 additions & 1 deletion docs/reference/fields.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1411,10 +1411,12 @@ Mongoid permits dynamic field names to include spaces and punctuation:
# => "MDB"


.. _localized-fields:

Localized Fields
================

Mongoid supports localized fields via `i18n <https://github.com/ruby-i18n/i18n>`_.
Mongoid supports localized fields via the `I18n gem <https://github.com/ruby-i18n/i18n>`_.

.. code-block:: ruby

Expand Down
12 changes: 0 additions & 12 deletions gemfiles/i18n-1.0.gemfile

This file was deleted.

39 changes: 6 additions & 33 deletions spec/integration/i18n_fallbacks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,39 +36,12 @@
end

context 'when translation is missing in all locales' do

context 'i18n >= 1.1' do

before(:all) do
unless Gem::Version.new(I18n::VERSION) >= Gem::Version.new('1.1')
skip "Test requires i18n >= 1.1, we have #{I18n::VERSION}"
end
end

it 'returns nil' do
product = Product.new
I18n.locale = :en
product.description = "Marvelous!"
I18n.locale = :ru
product.description.should be nil
end
end

context 'i18n 1.0' do

before(:all) do
unless Gem::Version.new(I18n::VERSION) < Gem::Version.new('1.1')
skip "Test requires i18n < 1.1, we have #{I18n::VERSION}"
end
end

it 'falls back on default locale' do
product = Product.new
I18n.locale = :en
product.description = "Marvelous!"
I18n.locale = :ru
product.description.should == 'Marvelous!'
end
it 'returns nil' do
product = Product.new
I18n.locale = :en
product.description = "Marvelous!"
I18n.locale = :ru
product.description.should be nil
end
end
end
Expand Down
4 changes: 1 addition & 3 deletions spec/mongoid/validatable/uniqueness_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2533,9 +2533,7 @@ class SpanishActor < EuropeanActor
end

after do
# i18n 1.0 requires +send+ because +translations+ aren't public.
# Newer i18n versions have it as public.
I18n.backend.send(:translations).delete(:fr)
I18n.backend.translations.delete(:fr)
end

it "correctly translates the error message" do
Expand Down
2 changes: 1 addition & 1 deletion spec/shared

0 comments on commit 0cde1be

Please sign in to comment.