FIX: wasn't able to update user options anymore

This commit is contained in:
Régis Hanol 2017-09-26 20:00:10 +02:00
parent 460ed3c8cf
commit 28c54b42c5
2 changed files with 13 additions and 7 deletions

View File

@ -849,7 +849,7 @@ class UsersController < ApplicationController
end
def user_params
result = params.permit(
permitted = [
:name,
:email,
:password,
@ -858,11 +858,15 @@ class UsersController < ApplicationController
:muted_usernames,
:theme_key,
:locale
).reverse_merge(
ip_address: request.remote_ip,
registration_ip_address: request.remote_ip,
locale: user_locale
)
] + UserUpdater::OPTION_ATTR
result = params
.permit(permitted)
.reverse_merge(
ip_address: request.remote_ip,
registration_ip_address: request.remote_ip,
locale: user_locale
)
if !UsernameCheckerService.is_developer?(result['email']) &&
is_api? &&

View File

@ -1440,13 +1440,15 @@ describe UsersController do
put :update, params: {
username: user.username,
muted_usernames: "",
theme_key: theme.key
theme_key: theme.key,
email_direct: false
}, format: :json
user.reload
expect(user.muted_users.pluck(:username).sort).to be_empty
expect(user.user_option.theme_key).to eq(theme.key)
expect(user.user_option.email_direct).to eq(false)
end