Remove body_as_json in favor of built-in response.parsed_body for JSON response specs (#31749)
This commit is contained in:
@@ -39,8 +39,6 @@ RSpec.describe FollowerAccountsController do
|
||||
end
|
||||
|
||||
context 'when format is json' do
|
||||
subject(:body) { response.parsed_body }
|
||||
|
||||
let(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } }
|
||||
|
||||
context 'with page' do
|
||||
@@ -48,15 +46,15 @@ RSpec.describe FollowerAccountsController do
|
||||
|
||||
it 'returns followers' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json)
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
orderedItems: contain_exactly(
|
||||
include(follow_from_bob.account.username),
|
||||
include(follow_from_chris.account.username)
|
||||
)
|
||||
),
|
||||
totalItems: eq(2),
|
||||
partOf: be_present
|
||||
)
|
||||
expect(body['totalItems']).to eq 2
|
||||
expect(body['partOf']).to be_present
|
||||
end
|
||||
|
||||
context 'when account is permanently suspended' do
|
||||
@@ -86,8 +84,11 @@ RSpec.describe FollowerAccountsController do
|
||||
|
||||
it 'returns followers' do
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body['totalItems']).to eq 2
|
||||
expect(body['partOf']).to be_blank
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
totalItems: eq(2)
|
||||
)
|
||||
.and not_include(:partOf)
|
||||
end
|
||||
|
||||
context 'when account hides their network' do
|
||||
@@ -95,15 +96,17 @@ RSpec.describe FollowerAccountsController do
|
||||
alice.update(hide_collections: true)
|
||||
end
|
||||
|
||||
it 'returns followers count' do
|
||||
expect(body['totalItems']).to eq 2
|
||||
end
|
||||
|
||||
it 'does not return items' do
|
||||
expect(body['items']).to be_blank
|
||||
expect(body['orderedItems']).to be_blank
|
||||
expect(body['first']).to be_blank
|
||||
expect(body['last']).to be_blank
|
||||
it 'returns followers count but not any items' do
|
||||
expect(response.parsed_body)
|
||||
.to include(
|
||||
totalItems: eq(2)
|
||||
)
|
||||
.and not_include(
|
||||
:items,
|
||||
:orderedItems,
|
||||
:first,
|
||||
:last
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user