diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 64b7fc8ac..15fd6de00 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -91,7 +91,10 @@ class UsersController < ApplicationController result = user.change_username(params[:new_username]) raise Discourse::InvalidParameters.new(:new_username) unless result - render nothing: true + render json: { + id: user.id, + username: user.username + } end def check_emails diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index f682ab631..b6f7cb15c 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -636,6 +636,11 @@ describe UsersController do response.should be_success end + it 'should return a JSON response with the updated username' do + xhr :put, :username, username: user.username, new_username: new_username + ::JSON.parse(response.body)['username'].should == new_username + end + end end