Prefer structure checks over multi-line size/parts checks in parsed_body
(#32063)
This commit is contained in:
parent
d6f5ee75ab
commit
51777fe3e2
6 changed files with 60 additions and 37 deletions
|
@ -23,8 +23,11 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
|
|||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
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)
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: alice.id.to_s),
|
||||
hash_including(id: bob.id.to_s)
|
||||
)
|
||||
end
|
||||
|
||||
it 'does not return blocked users', :aggregate_failures do
|
||||
|
@ -34,8 +37,10 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
|
|||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to eq 1
|
||||
expect(response.parsed_body[0][:id]).to eq alice.id.to_s
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: alice.id.to_s)
|
||||
)
|
||||
end
|
||||
|
||||
context 'when requesting user is blocked' do
|
||||
|
@ -56,8 +61,11 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
|
|||
account.mute!(bob)
|
||||
get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers
|
||||
|
||||
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)
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: alice.id.to_s),
|
||||
hash_including(id: bob.id.to_s)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,8 +23,11 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
|
|||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
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)
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: alice.id.to_s),
|
||||
hash_including(id: bob.id.to_s)
|
||||
)
|
||||
end
|
||||
|
||||
it 'does not return blocked users', :aggregate_failures do
|
||||
|
@ -34,8 +37,10 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
|
|||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to eq 1
|
||||
expect(response.parsed_body[0][:id]).to eq alice.id.to_s
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: alice.id.to_s)
|
||||
)
|
||||
end
|
||||
|
||||
context 'when requesting user is blocked' do
|
||||
|
@ -56,8 +61,11 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
|
|||
account.mute!(bob)
|
||||
get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers
|
||||
|
||||
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)
|
||||
expect(response.parsed_body)
|
||||
.to contain_exactly(
|
||||
hash_including(id: alice.id.to_s),
|
||||
hash_including(id: bob.id.to_s)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue