Use more generic locale as fallback for rules (#34756)
This commit is contained in:
parent
97b9e8849d
commit
6ab96ba647
4 changed files with 15 additions and 4 deletions
|
@ -36,4 +36,15 @@ RSpec.describe Rule do
|
|||
.to change { described_class.ordered.pluck(:text) }.from(%w(foo baz bar)).to(%w(foo bar baz))
|
||||
end
|
||||
end
|
||||
|
||||
describe '#translation_for' do
|
||||
let!(:rule) { Fabricate(:rule, text: 'This is a rule', hint: 'This is an explanation of the rule') }
|
||||
let!(:translation) { Fabricate(:rule_translation, rule: rule, text: 'Ceci est une règle', hint: 'Ceci est une explication de la règle', language: 'fr') }
|
||||
|
||||
it 'returns the expected translation, including fallbacks' do
|
||||
expect(rule.translation_for(:en)).to have_attributes(text: rule.text, hint: rule.hint)
|
||||
expect(rule.translation_for(:fr)).to have_attributes(text: translation.text, hint: translation.hint)
|
||||
expect(rule.translation_for(:'fr-CA')).to have_attributes(text: translation.text, hint: translation.hint)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue