diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index fdc528d3e9..e77f3d4b12 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -18,7 +18,7 @@ def update if @user.update(user_params) respond_to do |format| format.html { redirect_to @user } - format.json { head :no_content } + format.json { render :show } end else respond_to do |format| diff --git a/docs/api/sections/users.md b/docs/api/sections/users.md index 0d4d2889a2..6af8e88c2c 100644 --- a/docs/api/sections/users.md +++ b/docs/api/sections/users.md @@ -88,7 +88,7 @@ __Request:__ __Response:__ -Returns `204 No Content` on success. +Returns `200 OK` with the updated user in the same shape as `GET /:account_slug/users/:user_id`. ## `DELETE /:account_slug/users/:user_id/avatar` diff --git a/test/controllers/api/flat_json_params_test.rb b/test/controllers/api/flat_json_params_test.rb index 77a74f454e..4f847b1068 100644 --- a/test/controllers/api/flat_json_params_test.rb +++ b/test/controllers/api/flat_json_params_test.rb @@ -184,8 +184,10 @@ class FlatJsonParamsTest < ActionDispatch::IntegrationTest test "update user with flat JSON" do put user_path(users(:david)), params: { name: "Flat Name" }, as: :json - assert_response :no_content + assert_response :success assert_equal "Flat Name", users(:david).reload.name + assert_equal users(:david).id, @response.parsed_body["id"] + assert_equal "Flat Name", @response.parsed_body["name"] end test "create webhook with flat JSON" do diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index 7fd9fd28da..dcadefccec 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -120,8 +120,12 @@ class UsersControllerTest < ActionDispatch::IntegrationTest put user_path(users(:david)), params: { user: { name: "New David" } }, as: :json - assert_response :no_content + assert_response :success assert_equal "New David", users(:david).reload.name + + json = @response.parsed_body + assert_equal users(:david).id, json["id"] + assert_equal "New David", json["name"] end test "update as JSON with invalid avatar returns errors" do