From a61519eebf85f09fbddf55753e42c3f911766cc7 Mon Sep 17 00:00:00 2001 From: Blake Erickson Date: Sat, 6 Dec 2014 09:26:32 -0700 Subject: [PATCH] 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. --- app/controllers/users_controller.rb | 2 +- spec/controllers/users_controller_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6295f0b21ac..6928cc579b3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -500,7 +500,7 @@ class UsersController < ApplicationController end user.save! - render nothing: true + render json: success_json end def destroy_user_image diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 192e000ccaf..d5f203e61b5 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -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