Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mastofe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Pleroma
mastofe
Commits
d87ee116
Commit
d87ee116
authored
7 years ago
by
saturday06
Committed by
Eugen
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Assign user locale on signup (#1982)
parent
64e1d510
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/controllers/auth/registrations_controller.rb
+1
-0
1 addition, 0 deletions
app/controllers/auth/registrations_controller.rb
spec/controllers/auth/registrations_controller_spec.rb
+6
-1
6 additions, 1 deletion
spec/controllers/auth/registrations_controller_spec.rb
with
7 additions
and
1 deletion
app/controllers/auth/registrations_controller.rb
+
1
−
0
View file @
d87ee116
...
...
@@ -10,6 +10,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController
def
build_resource
(
hash
=
nil
)
super
(
hash
)
resource
.
locale
=
I18n
.
locale
resource
.
build_account
if
resource
.
account
.
nil?
end
...
...
This diff is collapsed.
Click to expand it.
spec/controllers/auth/registrations_controller_spec.rb
+
6
−
1
View file @
d87ee116
...
...
@@ -16,9 +16,12 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
end
describe
'POST #create'
do
let
(
:accept_language
)
{
Rails
.
application
.
config
.
i18n
.
available_locales
.
sample
.
to_s
}
before
do
Setting
.
open_registrations
=
true
request
.
env
[
"devise.mapping"
]
=
Devise
.
mappings
[
:user
]
request
.
headers
[
"Accept-Language"
]
=
accept_language
post
:create
,
params:
{
user:
{
account_attributes:
{
username:
'test'
},
email:
'test@example.com'
,
password:
'12345678'
,
password_confirmation:
'12345678'
}
}
end
...
...
@@ -27,7 +30,9 @@ RSpec.describe Auth::RegistrationsController, type: :controller do
end
it
'creates user'
do
expect
(
User
.
find_by
(
email:
'test@example.com'
)).
to_not
be_nil
user
=
User
.
find_by
(
email:
'test@example.com'
)
expect
(
user
).
to_not
be_nil
expect
(
user
.
locale
).
to
eq
(
accept_language
)
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment