mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-04-25 05:23:36 -04:00
FIX: make sure we also save the user_avatar.custom_upload_id
This commit is contained in:
parent
95fb32f3e5
commit
cb025a65e0
2 changed files with 6 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue