FIX: Re-enable invalid interpolation keys check and allow default keys to be left out of translation overrides.

https://meta.discourse.org/t/bulk-invite-from-file-resets-the-invite-forum-mailer-customized-text/67606/16
This commit is contained in:
Guo Xiang Tan
2017-11-20 16:10:06 +08:00
parent 2e04ef97d9
commit 5805979e88
6 changed files with 83 additions and 21 deletions

View File

@@ -10,14 +10,29 @@ describe TranslationOverride do
describe 'when interpolation keys are missing' do
it 'should not be valid' do
translation_override = TranslationOverride.upsert!(
I18n.locale, 'some_key', '%{first}'
I18n.locale, 'some_key', '%{key} %{omg}'
)
expect(translation_override.errors.full_messages).to include(I18n.t(
'activerecord.errors.models.translation_overrides.attributes.value.missing_interpolation_keys',
keys: 'second'
'activerecord.errors.models.translation_overrides.attributes.value.invalid_interpolation_keys',
keys: 'key, omg'
))
end
context 'when custom interpolation keys are included' do
it 'should be valid' do
translation_override = TranslationOverride.upsert!(
I18n.locale,
'some_key',
"#{described_class::CUSTOM_INTERPOLATION_KEYS_WHITELIST['user_notifications.user_'].join(", ")} %{something}"
)
expect(translation_override.errors.full_messages).to include(I18n.t(
'activerecord.errors.models.translation_overrides.attributes.value.invalid_interpolation_keys',
keys: 'something'
))
end
end
end
end
end