mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: make sure we also save the user_avatar.custom_upload_id
This commit is contained in:
parent
95fb32f3e5
commit
cb025a65e0
@ -503,15 +503,18 @@ class UsersController < ApplicationController
|
||||
def pick_avatar
|
||||
user = fetch_user_from_params
|
||||
guardian.ensure_can_edit!(user)
|
||||
|
||||
upload_id = params[:upload_id]
|
||||
|
||||
user.uploaded_avatar_id = upload_id
|
||||
|
||||
# ensure we associate the custom avatar properly
|
||||
if upload_id && !user.user_avatar.contains_upload?(upload_id)
|
||||
if upload_id && user.user_avatar.custom_upload_id != upload_id
|
||||
user.user_avatar.custom_upload_id = upload_id
|
||||
end
|
||||
|
||||
user.save!
|
||||
user.user_avatar.save!
|
||||
|
||||
render json: success_json
|
||||
end
|
||||
|
@ -1323,10 +1323,12 @@ describe UsersController do
|
||||
it 'it successful' do
|
||||
xhr :put, :pick_avatar, username: user.username, upload_id: 111
|
||||
expect(user.reload.uploaded_avatar_id).to eq(111)
|
||||
expect(user.user_avatar.reload.custom_upload_id).to eq(111)
|
||||
expect(response).to be_success
|
||||
|
||||
xhr :put, :pick_avatar, username: user.username
|
||||
expect(user.reload.uploaded_avatar_id).to eq(nil)
|
||||
expect(user.user_avatar.reload.custom_upload_id).to eq(111)
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user