Have pick_avatar return json.

I'm working on writing a test in the discourse_api gem for uploading
avatars and the pick method needs to return a json response.

I also added a test to make sure json is returned.
This commit is contained in:
Blake Erickson 2014-12-06 09:26:32 -07:00
parent 5ec77d4be4
commit a61519eebf
2 changed files with 8 additions and 1 deletions

View file

@ -500,7 +500,7 @@ class UsersController < ApplicationController
end
user.save!
render nothing: true
render json: success_json
end
def destroy_user_image

View file

@ -1292,6 +1292,13 @@ describe UsersController do
response.should be_success
end
it 'returns success' do
xhr :put, :pick_avatar, username: user.username, upload_id: 111
user.reload.uploaded_avatar_id.should == 111
response.should be_success
json = ::JSON.parse(response.body)
json['success'].should == "OK"
end
end
end