mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
REFACTOR: DRY up code and add better test coverage.
This commit is contained in:
@@ -110,15 +110,15 @@ class UserUpdater
|
||||
update_muted_users(attributes[:muted_usernames])
|
||||
end
|
||||
|
||||
saved = (!save_options || user.user_option.save) && user_profile.save && user.save
|
||||
if (saved = (!save_options || user.user_option.save) && user_profile.save && user.save) &&
|
||||
(attributes[:name].present? && old_user_name.casecmp(attributes.fetch(:name)) != 0) ||
|
||||
(attributes[:name].blank? && old_user_name.present?)
|
||||
|
||||
if saved
|
||||
# log name changes
|
||||
if attributes[:name].present? && old_user_name.downcase != attributes.fetch(:name).downcase
|
||||
StaffActionLogger.new(@actor).log_name_change(user.id, old_user_name, attributes.fetch(:name))
|
||||
elsif attributes[:name].blank? && old_user_name.present?
|
||||
StaffActionLogger.new(@actor).log_name_change(user.id, old_user_name, "")
|
||||
end
|
||||
StaffActionLogger.new(@actor).log_name_change(
|
||||
user.id,
|
||||
old_user_name,
|
||||
attributes.fetch(:name) { '' }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user