Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
94a4abc9
Commit
94a4abc9
authored
Sep 28, 2021
by
Baodong
Committed by
Vitali Tatarintev
Sep 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor user default preferred_language
parent
f3401aac
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
app/models/user.rb
app/models/user.rb
+6
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+2
-1
No files found.
app/models/user.rb
View file @
94a4abc9
...
@@ -455,7 +455,7 @@ class User < ApplicationRecord
...
@@ -455,7 +455,7 @@ class User < ApplicationRecord
def
preferred_language
def
preferred_language
read_attribute
(
'preferred_language'
)
||
read_attribute
(
'preferred_language'
)
||
I18n
.
default_locale
.
to_s
.
presence_in
(
Gitlab
::
I18n
.
available_locales
)
||
I18n
.
default_locale
.
to_s
.
presence_in
(
Gitlab
::
I18n
.
available_locales
)
||
'en'
default_preferred_language
end
end
def
active_for_authentication?
def
active_for_authentication?
...
@@ -2004,6 +2004,11 @@ class User < ApplicationRecord
...
@@ -2004,6 +2004,11 @@ class User < ApplicationRecord
private
private
# To enable JiHu repository to modify the default language options
def
default_preferred_language
'en'
end
def
notification_email_verified
def
notification_email_verified
return
if
notification_email
.
blank?
||
temp_oauth_email?
return
if
notification_email
.
blank?
||
temp_oauth_email?
...
...
spec/models/user_spec.rb
View file @
94a4abc9
...
@@ -343,8 +343,9 @@ RSpec.describe User do
...
@@ -343,8 +343,9 @@ RSpec.describe User do
it
'falls back to english when I18n.default_locale is not an available language'
do
it
'falls back to english when I18n.default_locale is not an available language'
do
I18n
.
default_locale
=
:kl
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
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment