Fix build with a better fix than 21b487a49d

And remove a test that can not happen
pull/11711/head
Christophe Bliard 2 years ago
parent f155412bcc
commit 4ffa0b16e7
No known key found for this signature in database
GPG Key ID: 2BC07603210C3FA4
  1. 13
      modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/message_bird.rb
  2. 26
      modules/two_factor_authentication/spec/lib/token_strategies/message_bird_spec.rb
  3. 5
      spec/support/i18n_lazy_loading.rb

@ -159,13 +159,12 @@ module OpenProject::TwoFactorAuthentication
pause = '<break time="500ms"/>' pause = '<break time="500ms"/>'
end end
I18n.with_locale(locale_key) do I18n.t "two_factor_authentication.text_otp_delivery_message_#{channel}",
I18n.t "two_factor_authentication.text_otp_delivery_message_#{channel}", pause:,
pause:, token: token_value,
token: token_value, locale: locale_key,
app_title: Setting.app_title, app_title: Setting.app_title,
fallback:, raise: raise_on_missing fallback:, raise: raise_on_missing
end
end end
## ##

@ -44,27 +44,13 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::MessageBird do
let(:locale) { 'de' } let(:locale) { 'de' }
it 'returns the correct language and message' do it 'returns the correct language and message' do
expect(I18n).to receive(:t) expected_message = I18n.t("two_factor_authentication.text_otp_delivery_message_sms",
.twice app_title: Setting.app_title,
.with('two_factor_authentication.text_otp_delivery_message_sms', locale: 'de',
hash_including(locale: 'de')) token: '1234')
.and_return 'localized string'
expect(subject[:language]).to eq :'de-de' expect(subject[:language]).to be :'de-de'
expect(subject[:message]).to eq 'localized string' expect(subject[:message]).to eql expected_message
end
end
context 'unsupported locale' do
before do
allow(user).to receive(:language).and_return 'unsupported'
# Allow I18n to receive unsupported language
allow(I18n).to receive(:enforce_available_locales!).and_call_original
allow(I18n).to receive(:enforce_available_locales!).with('unsupported')
end
it 'falls back to english' do
expect(subject[:language]).to eq :'en-us'
end end
end end
end end

@ -56,6 +56,11 @@ module I18nLazyLoading
I18nLazyLoading.load_locale(locale) I18nLazyLoading.load_locale(locale)
super super
end end
def t(*args, **options)
I18nLazyLoading.load_locale(options[:locale]) if options[:locale]
super
end
end end
def self.install def self.install

Loading…
Cancel
Save