From 8ed13bc6f7aa886058105066560dfa5143dfffeb Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Mon, 16 Mar 2026 10:40:03 -0400 Subject: [PATCH] Use `to_json` call for accounts API (#38226) --- app/controllers/api/v1/accounts_controller.rb | 2 +- spec/requests/api/v1/accounts_spec.rb | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb index 936cd56eb8..8738da3c94 100644 --- a/app/controllers/api/v1/accounts_controller.rb +++ b/app/controllers/api/v1/accounts_controller.rb @@ -38,7 +38,7 @@ class Api::V1::AccountsController < Api::BaseController headers.merge!(response.headers) - self.response_body = Oj.dump(response.body) + self.response_body = response.body.to_json self.status = response.status rescue ActiveRecord::RecordInvalid => e render json: ValidationErrorFormatter.new(e, 'account.username': :username, 'invite_request.text': :reason).as_json, status: 422 diff --git a/spec/requests/api/v1/accounts_spec.rb b/spec/requests/api/v1/accounts_spec.rb index e3416fc337..0ea5c3921e 100644 --- a/spec/requests/api/v1/accounts_spec.rb +++ b/spec/requests/api/v1/accounts_spec.rb @@ -185,7 +185,12 @@ RSpec.describe '/api/v1/accounts' do expect(response).to have_http_status(200) expect(response.content_type) .to start_with('application/json') - expect(response.parsed_body[:access_token]).to_not be_blank + expect(response.parsed_body) + .to include( + access_token: be_present, + created_at: be_a(Integer), + token_type: 'Bearer' + ) user = User.find_by(email: 'hello@world.tld') expect(user).to_not be_nil