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
|
@ -20,7 +20,7 @@ RSpec.describe 'credentials API' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(body_as_json).to include({
|
||||
expect(response.parsed_body).to include({
|
||||
source: hash_including({
|
||||
discoverable: false,
|
||||
indexable: false,
|
||||
|
@ -37,7 +37,7 @@ RSpec.describe 'credentials API' do
|
|||
|
||||
expect(response).to have_http_status(200)
|
||||
|
||||
expect(body_as_json).to include({
|
||||
expect(response.parsed_body).to include({
|
||||
locked: true,
|
||||
})
|
||||
end
|
||||
|
@ -93,7 +93,7 @@ RSpec.describe 'credentials API' do
|
|||
expect(response)
|
||||
.to have_http_status(200)
|
||||
|
||||
expect(body_as_json).to include({
|
||||
expect(response.parsed_body).to include({
|
||||
source: hash_including({
|
||||
discoverable: true,
|
||||
indexable: true,
|
||||
|
|
|
@ -24,7 +24,7 @@ RSpec.describe 'Accounts Familiar Followers API' do
|
|||
account_ids = [account_a, account_b, account_b, account_a, account_a].map { |a| a.id.to_s }
|
||||
get '/api/v1/accounts/familiar_followers', params: { id: account_ids }, headers: headers
|
||||
|
||||
expect(body_as_json.pluck(:id)).to contain_exactly(account_a.id.to_s, account_b.id.to_s)
|
||||
expect(response.parsed_body.pluck(:id)).to contain_exactly(account_a.id.to_s, account_b.id.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ RSpec.describe 'account featured tags API' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json).to contain_exactly(a_hash_including({
|
||||
expect(response.parsed_body).to contain_exactly(a_hash_including({
|
||||
name: 'bar',
|
||||
url: "https://cb6e6126.ngrok.io/@#{account.username}/tagged/bar",
|
||||
}), a_hash_including({
|
||||
|
@ -37,7 +37,7 @@ RSpec.describe 'account featured tags API' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json).to contain_exactly(a_hash_including({
|
||||
expect(response.parsed_body).to contain_exactly(a_hash_including({
|
||||
name: 'bar',
|
||||
url: "https://cb6e6126.ngrok.io/@#{account.pretty_acct}/tagged/bar",
|
||||
}), a_hash_including({
|
||||
|
|
|
@ -21,8 +21,8 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
|
|||
get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json.size).to eq 2
|
||||
expect([body_as_json[0][:id], body_as_json[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
|
||||
expect(response.parsed_body.size).to eq 2
|
||||
expect([response.parsed_body[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
|
||||
end
|
||||
|
||||
it 'does not return blocked users', :aggregate_failures do
|
||||
|
@ -30,8 +30,8 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
|
|||
get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json.size).to eq 1
|
||||
expect(body_as_json[0][:id]).to eq alice.id.to_s
|
||||
expect(response.parsed_body.size).to eq 1
|
||||
expect(response.parsed_body[0][:id]).to eq alice.id.to_s
|
||||
end
|
||||
|
||||
context 'when requesting user is blocked' do
|
||||
|
@ -41,7 +41,7 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
|
|||
|
||||
it 'hides results' do
|
||||
get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers
|
||||
expect(body_as_json.size).to eq 0
|
||||
expect(response.parsed_body.size).to eq 0
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -52,8 +52,8 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
|
|||
account.mute!(bob)
|
||||
get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(body_as_json.size).to eq 2
|
||||
expect([body_as_json[0][:id], body_as_json[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
|
||||
expect(response.parsed_body.size).to eq 2
|
||||
expect([response.parsed_body[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,8 +21,8 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
|
|||
get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json.size).to eq 2
|
||||
expect([body_as_json[0][:id], body_as_json[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
|
||||
expect(response.parsed_body.size).to eq 2
|
||||
expect([response.parsed_body[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
|
||||
end
|
||||
|
||||
it 'does not return blocked users', :aggregate_failures do
|
||||
|
@ -30,8 +30,8 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
|
|||
get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json.size).to eq 1
|
||||
expect(body_as_json[0][:id]).to eq alice.id.to_s
|
||||
expect(response.parsed_body.size).to eq 1
|
||||
expect(response.parsed_body[0][:id]).to eq alice.id.to_s
|
||||
end
|
||||
|
||||
context 'when requesting user is blocked' do
|
||||
|
@ -41,7 +41,7 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
|
|||
|
||||
it 'hides results' do
|
||||
get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers
|
||||
expect(body_as_json.size).to eq 0
|
||||
expect(response.parsed_body.size).to eq 0
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -52,8 +52,8 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
|
|||
account.mute!(bob)
|
||||
get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(body_as_json.size).to eq 2
|
||||
expect([body_as_json[0][:id], body_as_json[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
|
||||
expect(response.parsed_body.size).to eq 2
|
||||
expect([response.parsed_body[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(body_as_json)
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
.and contain_exactly(
|
||||
include(
|
||||
|
@ -50,7 +50,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(body_as_json)
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
.and have_attributes(
|
||||
size: 2
|
||||
|
@ -70,7 +70,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(body_as_json)
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
.and have_attributes(
|
||||
size: 3
|
||||
|
@ -89,7 +89,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
it 'removes duplicate account IDs from params' do
|
||||
subject
|
||||
|
||||
expect(body_as_json)
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
.and have_attributes(
|
||||
size: 2
|
||||
|
@ -141,7 +141,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
it 'returns JSON with correct data on previously cached requests' do
|
||||
# Initial request including multiple accounts in params
|
||||
get '/api/v1/accounts/relationships', headers: headers, params: { id: [simon.id, lewis.id] }
|
||||
expect(body_as_json)
|
||||
expect(response.parsed_body)
|
||||
.to have_attributes(size: 2)
|
||||
|
||||
# Subsequent request with different id, should override cache from first request
|
||||
|
@ -150,7 +150,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
expect(response)
|
||||
.to have_http_status(200)
|
||||
|
||||
expect(body_as_json)
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
.and have_attributes(
|
||||
size: 1
|
||||
|
@ -172,7 +172,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
expect(response)
|
||||
.to have_http_status(200)
|
||||
|
||||
expect(body_as_json)
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
.and contain_exactly(
|
||||
include(
|
||||
|
|
|
@ -41,7 +41,7 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
it 'returns posts along with self replies', :aggregate_failures do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(body_as_json)
|
||||
expect(response.parsed_body)
|
||||
.to have_attributes(size: 2)
|
||||
.and contain_exactly(
|
||||
include(id: status.id.to_s),
|
||||
|
@ -102,7 +102,7 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
it 'lists the public status only' do
|
||||
get "/api/v1/accounts/#{account.id}/statuses", params: { pinned: true }, headers: headers
|
||||
|
||||
expect(body_as_json)
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
a_hash_including(id: status.id.to_s)
|
||||
)
|
||||
|
@ -117,7 +117,7 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
it 'lists both the public and the private statuses' do
|
||||
get "/api/v1/accounts/#{account.id}/statuses", params: { pinned: true }, headers: headers
|
||||
|
||||
expect(body_as_json)
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
a_hash_including(id: status.id.to_s),
|
||||
a_hash_including(id: private_status.id.to_s)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue