Commit 94a4abc9 authored by Baodong's avatar Baodong Committed by Vitali Tatarintev

Refactor user default preferred_language

parent f3401aac
......@@ -455,7 +455,7 @@ class User < ApplicationRecord
def preferred_language
read_attribute('preferred_language') ||
I18n.default_locale.to_s.presence_in(Gitlab::I18n.available_locales) ||
'en'
default_preferred_language
end
def active_for_authentication?
......@@ -2004,6 +2004,11 @@ class User < ApplicationRecord
private
# To enable JiHu repository to modify the default language options
def default_preferred_language
'en'
end
def notification_email_verified
return if notification_email.blank? || temp_oauth_email?
......
......@@ -343,8 +343,9 @@ RSpec.describe User do
it 'falls back to english when I18n.default_locale is not an available language' do
I18n.default_locale = :kl
default_preferred_language = user.send(:default_preferred_language)
expect(user.preferred_language).to eq 'en'
expect(user.preferred_language).to eq default_preferred_language
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment