mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
FIX: status was clearing after editing user preferences (#18887)
The problem was reported as a problem with changing theme in user preferences, after saving a new theme the previously set user status was disappearing (https://meta.discourse.org/t/user-status/240335/42). Turned out though that the problem was more wide, changing pretty much any setting in user preferences apart from user status itself led to clearing the status.
This commit is contained in:
parent
cf51a4ea84
commit
ce7172bc9b
@ -1966,6 +1966,7 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
if SiteSetting.enable_user_status
|
||||
permitted << :status
|
||||
permitted << { status: [:emoji, :description, :ends_at] }
|
||||
end
|
||||
|
||||
|
@ -216,7 +216,7 @@ class UserUpdater
|
||||
end
|
||||
|
||||
if SiteSetting.enable_user_status?
|
||||
update_user_status(attributes[:status])
|
||||
update_user_status(attributes[:status]) if attributes.has_key?(:status)
|
||||
end
|
||||
|
||||
name_changed = user.name_changed?
|
||||
|
@ -2578,6 +2578,25 @@ RSpec.describe UsersController do
|
||||
expect(user1.user_status).not_to be_nil
|
||||
end
|
||||
|
||||
it "doesn't clear user status if it wasn't sent in the payload" do
|
||||
new_status = {
|
||||
emoji: "off to dentist",
|
||||
description: "tooth",
|
||||
}
|
||||
user.set_status!(new_status[:description], new_status[:emoji])
|
||||
user.reload
|
||||
|
||||
put "/u/#{user.username}.json", params: {
|
||||
bio_raw: "new bio"
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
user.reload
|
||||
expect(user.user_status).not_to be_nil
|
||||
expect(user.user_status.emoji).to eq(new_status[:emoji])
|
||||
expect(user.user_status.description).to eq(new_status[:description])
|
||||
end
|
||||
|
||||
context 'when user status is disabled' do
|
||||
before do
|
||||
SiteSetting.enable_user_status = false
|
||||
|
Loading…
Reference in New Issue
Block a user