fix the build - take 2
This commit is contained in:
parent
29f25dbf6e
commit
18d7c1c75d
|
@ -49,10 +49,8 @@ export default RestrictedUserRoute.extend({
|
|||
const user = this.modelFor('user'),
|
||||
controller = this.controllerFor('avatar-selector'),
|
||||
selectedUploadId = controller.get("selectedUploadId"),
|
||||
selectedAvatarTemplate = controller.get("selectedAvatarTemplate");
|
||||
|
||||
let type = controller.get("selected");
|
||||
if (type === "uploaded") { type = "custom" }
|
||||
selectedAvatarTemplate = controller.get("selectedAvatarTemplate"),
|
||||
type = controller.get("selected");
|
||||
|
||||
user.pickAvatar(selectedUploadId, type, selectedAvatarTemplate)
|
||||
.then(() => {
|
||||
|
|
|
@ -531,13 +531,16 @@ class UsersController < ApplicationController
|
|||
user = fetch_user_from_params
|
||||
guardian.ensure_can_edit!(user)
|
||||
|
||||
type = params[:type]
|
||||
upload_id = params[:upload_id]
|
||||
|
||||
type = params[:type]
|
||||
type = "custom" if type == "uploaded"
|
||||
|
||||
user.uploaded_avatar_id = upload_id
|
||||
user.user_avatar.send("#{type}_upload_id=", upload_id)
|
||||
|
||||
if type == "uploaded" || type == "custom"
|
||||
user.user_avatar.custom_upload_id = upload_id
|
||||
elsif type == "gravatar"
|
||||
user.user_avatar.gravatar_upload_id = upload_id
|
||||
end
|
||||
|
||||
user.save!
|
||||
user.user_avatar.save!
|
||||
|
|
|
@ -1301,7 +1301,7 @@ describe UsersController do
|
|||
describe '.pick_avatar' do
|
||||
|
||||
it 'raises an error when not logged in' do
|
||||
expect { xhr :put, :pick_avatar, username: 'asdf', avatar_id: 1}.to raise_error(Discourse::NotLoggedIn)
|
||||
expect { xhr :put, :pick_avatar, username: 'asdf', avatar_id: 1, type: "custom"}.to raise_error(Discourse::NotLoggedIn)
|
||||
end
|
||||
|
||||
context 'while logged in' do
|
||||
|
@ -1310,12 +1310,12 @@ describe UsersController do
|
|||
|
||||
it 'raises an error when you don\'t have permission to toggle the avatar' do
|
||||
another_user = Fabricate(:user)
|
||||
xhr :put, :pick_avatar, username: another_user.username, upload_id: 1
|
||||
xhr :put, :pick_avatar, username: another_user.username, upload_id: 1, type: "custom"
|
||||
expect(response).to be_forbidden
|
||||
end
|
||||
|
||||
it 'it successful' do
|
||||
xhr :put, :pick_avatar, username: user.username, upload_id: 111
|
||||
xhr :put, :pick_avatar, username: user.username, upload_id: 111, type: "custom"
|
||||
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
|
||||
|
@ -1326,13 +1326,6 @@ describe UsersController do
|
|||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it 'returns success' do
|
||||
xhr :put, :pick_avatar, username: user.username, upload_id: 111
|
||||
expect(user.reload.uploaded_avatar_id).to eq(111)
|
||||
expect(response).to be_success
|
||||
json = ::JSON.parse(response.body)
|
||||
expect(json['success']).to eq("OK")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue