Remove body_as_json
in favor of built-in response.parsed_body
for JSON response specs (#31749)
This commit is contained in:
parent
be77a1098b
commit
6b6a80b407
107 changed files with 422 additions and 413 deletions
|
@ -17,7 +17,7 @@ RSpec.describe '/api/v1/accounts' do
|
|||
get '/api/v1/accounts', headers: headers, params: { id: [account.id, other_account.id, 123_123] }
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json).to contain_exactly(
|
||||
expect(response.parsed_body).to contain_exactly(
|
||||
hash_including(id: account.id.to_s),
|
||||
hash_including(id: other_account.id.to_s)
|
||||
)
|
||||
|
@ -32,7 +32,7 @@ RSpec.describe '/api/v1/accounts' do
|
|||
get "/api/v1/accounts/#{account.id}"
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json[:id]).to eq(account.id.to_s)
|
||||
expect(response.parsed_body[:id]).to eq(account.id.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,7 +41,7 @@ RSpec.describe '/api/v1/accounts' do
|
|||
get '/api/v1/accounts/1'
|
||||
|
||||
expect(response).to have_http_status(404)
|
||||
expect(body_as_json[:error]).to eq('Record not found')
|
||||
expect(response.parsed_body[:error]).to eq('Record not found')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -57,7 +57,7 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json[:id]).to eq(account.id.to_s)
|
||||
expect(response.parsed_body[:id]).to eq(account.id.to_s)
|
||||
end
|
||||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write:statuses'
|
||||
|
@ -80,7 +80,7 @@ RSpec.describe '/api/v1/accounts' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json[:access_token]).to_not be_blank
|
||||
expect(response.parsed_body[:access_token]).to_not be_blank
|
||||
|
||||
user = User.find_by(email: 'hello@world.tld')
|
||||
expect(user).to_not be_nil
|
||||
|
@ -114,7 +114,7 @@ RSpec.describe '/api/v1/accounts' do
|
|||
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
expect(body_as_json)
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
following: true,
|
||||
requested: false
|
||||
|
@ -134,7 +134,7 @@ RSpec.describe '/api/v1/accounts' do
|
|||
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
expect(body_as_json)
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
following: false,
|
||||
requested: true
|
||||
|
@ -157,7 +157,7 @@ RSpec.describe '/api/v1/accounts' do
|
|||
it 'changes reblogs option' do
|
||||
post "/api/v1/accounts/#{other_account.id}/follow", headers: headers, params: { reblogs: true }
|
||||
|
||||
expect(body_as_json).to include({
|
||||
expect(response.parsed_body).to include({
|
||||
following: true,
|
||||
showing_reblogs: true,
|
||||
notifying: false,
|
||||
|
@ -167,7 +167,7 @@ RSpec.describe '/api/v1/accounts' do
|
|||
it 'changes notify option' do
|
||||
post "/api/v1/accounts/#{other_account.id}/follow", headers: headers, params: { notify: true }
|
||||
|
||||
expect(body_as_json).to include({
|
||||
expect(response.parsed_body).to include({
|
||||
following: true,
|
||||
showing_reblogs: false,
|
||||
notifying: true,
|
||||
|
@ -177,7 +177,7 @@ RSpec.describe '/api/v1/accounts' do
|
|||
it 'changes languages option' do
|
||||
post "/api/v1/accounts/#{other_account.id}/follow", headers: headers, params: { languages: %w(en es) }
|
||||
|
||||
expect(body_as_json).to include({
|
||||
expect(response.parsed_body).to include({
|
||||
following: true,
|
||||
showing_reblogs: false,
|
||||
notifying: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue