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:
Andrei Prigorshnev
2022-11-16 21:42:56 +04:00
committed by GitHub
parent cf51a4ea84
commit ce7172bc9b
3 changed files with 21 additions and 1 deletions

View File

@ -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