Use to_json call for accounts API (#38226)
This commit is contained in:
parent
7933fa4f94
commit
8ed13bc6f7
@ -38,7 +38,7 @@ class Api::V1::AccountsController < Api::BaseController
|
|||||||
|
|
||||||
headers.merge!(response.headers)
|
headers.merge!(response.headers)
|
||||||
|
|
||||||
self.response_body = Oj.dump(response.body)
|
self.response_body = response.body.to_json
|
||||||
self.status = response.status
|
self.status = response.status
|
||||||
rescue ActiveRecord::RecordInvalid => e
|
rescue ActiveRecord::RecordInvalid => e
|
||||||
render json: ValidationErrorFormatter.new(e, 'account.username': :username, 'invite_request.text': :reason).as_json, status: 422
|
render json: ValidationErrorFormatter.new(e, 'account.username': :username, 'invite_request.text': :reason).as_json, status: 422
|
||||||
|
|||||||
@ -185,7 +185,12 @@ RSpec.describe '/api/v1/accounts' do
|
|||||||
expect(response).to have_http_status(200)
|
expect(response).to have_http_status(200)
|
||||||
expect(response.content_type)
|
expect(response.content_type)
|
||||||
.to start_with('application/json')
|
.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')
|
user = User.find_by(email: 'hello@world.tld')
|
||||||
expect(user).to_not be_nil
|
expect(user).to_not be_nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user