Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix build with a better fix than 21b487a49d

Christophe Bliard4ffa0b16e7aa
diff --git a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/message_bird.rb b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/message_bird.rb
index f51dcc911f9..a4840d225a0 100644
--- a/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/message_bird.rb
+++ b/modules/two_factor_authentication/lib/open_project/two_factor_authentication/token_strategy/message_bird.rb
@@ -159,13 +159,12 @@ module OpenProject::TwoFactorAuthentication
pause = '<break time="500ms"/>'
end
- I18n.with_locale(locale_key) do
- I18n.t "two_factor_authentication.text_otp_delivery_message_#{channel}",
- pause:,
- token: token_value,
- app_title: Setting.app_title,
- fallback:, raise: raise_on_missing
- end
+ I18n.t "two_factor_authentication.text_otp_delivery_message_#{channel}",
+ pause:,
+ token: token_value,
+ locale: locale_key,
+ app_title: Setting.app_title,
+ fallback:, raise: raise_on_missing
end
##
diff --git a/modules/two_factor_authentication/spec/lib/token_strategies/message_bird_spec.rb b/modules/two_factor_authentication/spec/lib/token_strategies/message_bird_spec.rb
index beb9ecc3d44..5520448b2c0 100644
--- a/modules/two_factor_authentication/spec/lib/token_strategies/message_bird_spec.rb
+++ b/modules/two_factor_authentication/spec/lib/token_strategies/message_bird_spec.rb
@@ -44,27 +44,13 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::MessageBird do
let(:locale) { 'de' }
it 'returns the correct language and message' do
- expect(I18n).to receive(:t)
- .twice
- .with('two_factor_authentication.text_otp_delivery_message_sms',
- hash_including(locale: 'de'))
- .and_return 'localized string'
+ expected_message = I18n.t("two_factor_authentication.text_otp_delivery_message_sms",
+ app_title: Setting.app_title,
+ locale: 'de',
+ token: '1234')
- expect(subject[:language]).to eq :'de-de'
- expect(subject[:message]).to eq 'localized string'
- 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'
+ expect(subject[:language]).to be :'de-de'
+ expect(subject[:message]).to eql expected_message
end
end
end
diff --git a/spec/support/i18n_lazy_loading.rb b/spec/support/i18n_lazy_loading.rb
index 64ea107c95c..de2d1acf7d6 100644
--- a/spec/support/i18n_lazy_loading.rb
+++ b/spec/support/i18n_lazy_loading.rb
@@ -56,6 +56,11 @@ module I18nLazyLoading
I18nLazyLoading.load_locale(locale)
super
end
+
+ def t(*args, **options)
+ I18nLazyLoading.load_locale(options[:locale]) if options[:locale]
+ super
+ end
end
def self.install