Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(Rails/I18nLocaleAssignment): manual #104

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -718,25 +718,6 @@ Rails/Delegate:
- 'lib/mongoid/findable.rb'
- 'lib/mongoid/scopable.rb'

# Offense count: 91
# Configuration parameters: Include.
# Include: spec/**/*.rb, test/**/*.rb
Rails/I18nLocaleAssignment:
Exclude:
- 'spec/integration/i18n_fallbacks_spec.rb'
- 'spec/mongoid/contextual/memory_spec.rb'
- 'spec/mongoid/contextual/mongo_spec.rb'
- 'spec/mongoid/copyable_spec.rb'
- 'spec/mongoid/criteria/queryable/options_spec.rb'
- 'spec/mongoid/criteria/queryable/selector_spec.rb'
- 'spec/mongoid/criteria_projection_spec.rb'
- 'spec/mongoid/criteria_spec.rb'
- 'spec/mongoid/fields/localized_spec.rb'
- 'spec/mongoid/fields_spec.rb'
- 'spec/mongoid/persistable/updatable_spec.rb'
- 'spec/mongoid/validatable/uniqueness_spec.rb'
- 'spec/support/macros.rb'

# Offense count: 133
# Configuration parameters: ForbiddenMethods, AllowedMethods.
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
Expand Down
33 changes: 16 additions & 17 deletions spec/integration/i18n_fallbacks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,37 @@
context 'when fallbacks are enabled with a locale list' do
with_default_i18n_configs

before do
I18n.fallbacks[:de] = [:en]
end
before { I18n.fallbacks[:de] = [:en] }

let(:product) { Product.new }

context 'when translation is present in active locale' do
it 'uses active locale' do
product = Product.new
I18n.locale = :de
around { |example| I18n.with_locale(:de) { example.run } }

before do
product.description = 'Marvelous in German'
I18n.locale = :en
product.description = 'Marvelous!'
I18n.locale = :de
I18n.with_locale(:en) { product.description = 'Marvelous!' }
end

it 'uses active locale' do
expect(product.description).to eq('Marvelous in German')
end
end

context 'when translation is missing in active locale and present in fallback locale' do
around { |example| I18n.with_locale(:de) { example.run } }
before { I18n.with_locale(:en) { product.description = 'Marvelous!' } }

it 'falls back on default locale' do
product = Product.new
I18n.locale = :en
product.description = 'Marvelous!'
I18n.locale = :de
expect(product.description).to eq('Marvelous!')
end
end

context 'when translation is missing in all locales' do
around { |example| I18n.with_locale(:ru) { example.run } }
before { I18n.with_locale(:en) { product.description = 'Marvelous!' } }

it 'returns nil' do
product = Product.new
I18n.locale = :en
product.description = 'Marvelous!'
I18n.locale = :ru
expect(product.description).to be_nil
end
end
Expand Down
Loading