Restore test of unsupported locale with message bird

And fix some rubocop linting advices
pull/11710/head
Christophe Bliard 2 years ago
parent e9e23bd93f
commit bbbdc9b947
No known key found for this signature in database
GPG Key ID: 2BC07603210C3FA4
  1. 24
      modules/two_factor_authentication/spec/lib/token_strategies/message_bird_spec.rb

@ -1,11 +1,11 @@
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
require_relative '../../spec_helper'
require 'messagebird'
describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::MessageBird do
let(:channel) { :sms }
let(:locale) { 'en' }
let(:user) { create :user, language: locale }
let(:device) { create :two_factor_authentication_device_sms, user:, channel: }
let(:user) { create(:user, language: locale) }
let(:device) { create(:two_factor_authentication_device_sms, user:, channel:) }
let(:strategy) { described_class.new user:, device:, channel: }
before do
@ -31,7 +31,7 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::MessageBird do
end
end
context 'en' do
context 'with en' do
let(:locale) { 'en' }
it 'returns the correct language and message' do
@ -40,7 +40,7 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::MessageBird do
end
end
context 'de' do
context 'with de' do
let(:locale) { 'de' }
it 'returns the correct language and message' do
@ -53,5 +53,19 @@ describe ::OpenProject::TwoFactorAuthentication::TokenStrategy::MessageBird do
expect(subject[:message]).to eql expected_message
end
end
context 'with unsupported locale ar (Arabic is not supported in message bird)' do
let(:locale) { 'ar' }
it 'falls back to english' do
expected_message = I18n.t("two_factor_authentication.text_otp_delivery_message_sms",
app_title: Setting.app_title,
locale: 'en',
token: '1234')
expect(subject[:language]).to eq :'en-us'
expect(subject[:message]).to eql expected_message
end
end
end
end

Loading…
Cancel
Save