Remove body_as_json in favor of built-in response.parsed_body for JSON response specs (#31749)

This commit is contained in:
Matt Jankowski 2024-09-06 05:58:46 -04:00 committed by GitHub
parent be77a1098b
commit 6b6a80b407
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
107 changed files with 422 additions and 413 deletions

View File

@ -31,7 +31,7 @@ RSpec.describe ActivityPub::CollectionsController do
.and have_cacheable_headers .and have_cacheable_headers
expect(response.media_type).to eq 'application/activity+json' expect(response.media_type).to eq 'application/activity+json'
expect(body_as_json[:orderedItems]) expect(response.parsed_body[:orderedItems])
.to be_an(Array) .to be_an(Array)
.and have_attributes(size: 3) .and have_attributes(size: 3)
.and include(ActivityPub::TagManager.instance.uri_for(private_pinned)) .and include(ActivityPub::TagManager.instance.uri_for(private_pinned))
@ -71,7 +71,7 @@ RSpec.describe ActivityPub::CollectionsController do
expect(response.media_type).to eq 'application/activity+json' expect(response.media_type).to eq 'application/activity+json'
expect(body_as_json[:orderedItems]) expect(response.parsed_body[:orderedItems])
.to be_an(Array) .to be_an(Array)
.and have_attributes(size: 3) .and have_attributes(size: 3)
.and include(ActivityPub::TagManager.instance.uri_for(private_pinned)) .and include(ActivityPub::TagManager.instance.uri_for(private_pinned))
@ -94,7 +94,7 @@ RSpec.describe ActivityPub::CollectionsController do
expect(response.media_type).to eq 'application/activity+json' expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to include 'private' expect(response.headers['Cache-Control']).to include 'private'
expect(body_as_json[:orderedItems]) expect(response.parsed_body[:orderedItems])
.to be_an(Array) .to be_an(Array)
.and be_empty .and be_empty
end end
@ -110,7 +110,7 @@ RSpec.describe ActivityPub::CollectionsController do
expect(response.media_type).to eq 'application/activity+json' expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to include 'private' expect(response.headers['Cache-Control']).to include 'private'
expect(body_as_json[:orderedItems]) expect(response.parsed_body[:orderedItems])
.to be_an(Array) .to be_an(Array)
.and be_empty .and be_empty
end end

View File

@ -34,7 +34,6 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController do
context 'with signature from example.com' do context 'with signature from example.com' do
subject(:response) { get :show, params: { account_username: account.username } } subject(:response) { get :show, params: { account_username: account.username } }
let(:body) { body_as_json }
let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') } let(:remote_account) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/instance') }
it 'returns http success and cache control and activity json types and correct items' do it 'returns http success and cache control and activity json types and correct items' do
@ -42,7 +41,7 @@ RSpec.describe ActivityPub::FollowersSynchronizationsController do
expect(response.headers['Cache-Control']).to eq 'max-age=0, private' expect(response.headers['Cache-Control']).to eq 'max-age=0, private'
expect(response.media_type).to eq 'application/activity+json' expect(response.media_type).to eq 'application/activity+json'
expect(body[:orderedItems]) expect(response.parsed_body[:orderedItems])
.to be_an(Array) .to be_an(Array)
.and contain_exactly( .and contain_exactly(
follower_example_com_instance_actor.uri, follower_example_com_instance_actor.uri,

View File

@ -19,7 +19,6 @@ RSpec.describe ActivityPub::OutboxesController do
context 'without signature' do context 'without signature' do
subject(:response) { get :show, params: { account_username: account.username, page: page } } subject(:response) { get :show, params: { account_username: account.username, page: page } }
let(:body) { body_as_json }
let(:remote_account) { nil } let(:remote_account) { nil }
context 'with page not requested' do context 'with page not requested' do
@ -32,7 +31,7 @@ RSpec.describe ActivityPub::OutboxesController do
expect(response.media_type).to eq 'application/activity+json' expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Vary']).to be_nil expect(response.headers['Vary']).to be_nil
expect(body[:totalItems]).to eq 4 expect(response.parsed_body[:totalItems]).to eq 4
end end
context 'when account is permanently suspended' do context 'when account is permanently suspended' do
@ -68,9 +67,11 @@ RSpec.describe ActivityPub::OutboxesController do
expect(response.media_type).to eq 'application/activity+json' expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Vary']).to include 'Signature' expect(response.headers['Vary']).to include 'Signature'
expect(body[:orderedItems]).to be_an Array expect(response.parsed_body)
expect(body[:orderedItems].size).to eq 2 .to include(
expect(body[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true orderedItems: be_an(Array).and(have_attributes(size: 2))
)
expect(response.parsed_body[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true
end end
context 'when account is permanently suspended' do context 'when account is permanently suspended' do
@ -110,9 +111,11 @@ RSpec.describe ActivityPub::OutboxesController do
expect(response.media_type).to eq 'application/activity+json' expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to eq 'max-age=60, private' expect(response.headers['Cache-Control']).to eq 'max-age=60, private'
expect(body_as_json[:orderedItems]).to be_an Array expect(response.parsed_body)
expect(body_as_json[:orderedItems].size).to eq 2 .to include(
expect(body_as_json[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true orderedItems: be_an(Array).and(have_attributes(size: 2))
)
expect(response.parsed_body[:orderedItems].all? { |item| targets_public_collection?(item) }).to be true
end end
end end
@ -127,9 +130,11 @@ RSpec.describe ActivityPub::OutboxesController do
expect(response.media_type).to eq 'application/activity+json' expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to eq 'max-age=60, private' expect(response.headers['Cache-Control']).to eq 'max-age=60, private'
expect(body_as_json[:orderedItems]).to be_an Array expect(response.parsed_body)
expect(body_as_json[:orderedItems].size).to eq 3 .to include(
expect(body_as_json[:orderedItems].all? { |item| targets_public_collection?(item) || targets_followers_collection?(item, account) }).to be true orderedItems: be_an(Array).and(have_attributes(size: 3))
)
expect(response.parsed_body[:orderedItems].all? { |item| targets_public_collection?(item) || targets_followers_collection?(item, account) }).to be true
end end
end end
@ -144,9 +149,10 @@ RSpec.describe ActivityPub::OutboxesController do
expect(response.media_type).to eq 'application/activity+json' expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to eq 'max-age=60, private' expect(response.headers['Cache-Control']).to eq 'max-age=60, private'
expect(body_as_json[:orderedItems]) expect(response.parsed_body)
.to be_an(Array) .to include(
.and be_empty orderedItems: be_an(Array).and(be_empty)
)
end end
end end
@ -161,9 +167,10 @@ RSpec.describe ActivityPub::OutboxesController do
expect(response.media_type).to eq 'application/activity+json' expect(response.media_type).to eq 'application/activity+json'
expect(response.headers['Cache-Control']).to eq 'max-age=60, private' expect(response.headers['Cache-Control']).to eq 'max-age=60, private'
expect(body_as_json[:orderedItems]) expect(response.parsed_body)
.to be_an(Array) .to include(
.and be_empty orderedItems: be_an(Array).and(be_empty)
)
end end
end end
end end

View File

@ -66,7 +66,7 @@ RSpec.describe ActivityPub::RepliesController do
context 'when status is public' do context 'when status is public' do
let(:parent_visibility) { :public } let(:parent_visibility) { :public }
let(:page_json) { body_as_json[:first] } let(:page_json) { response.parsed_body[:first] }
it 'returns http success and correct media type' do it 'returns http success and correct media type' do
expect(response) expect(response)

View File

@ -402,7 +402,7 @@ RSpec.describe Auth::SessionsController do
end end
it 'instructs the browser to redirect to home, logs the user in, and updates the sign count' do it 'instructs the browser to redirect to home, logs the user in, and updates the sign count' do
expect(body_as_json[:redirect_path]).to eq(root_path) expect(response.parsed_body[:redirect_path]).to eq(root_path)
expect(controller.current_user).to eq user expect(controller.current_user).to eq user

View File

@ -39,8 +39,6 @@ RSpec.describe FollowerAccountsController do
end end
context 'when format is json' do context 'when format is json' do
subject(:body) { response.parsed_body }
let(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } } let(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } }
context 'with page' do context 'with page' do
@ -48,15 +46,15 @@ RSpec.describe FollowerAccountsController do
it 'returns followers' do it 'returns followers' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
orderedItems: contain_exactly( orderedItems: contain_exactly(
include(follow_from_bob.account.username), include(follow_from_bob.account.username),
include(follow_from_chris.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 end
context 'when account is permanently suspended' do context 'when account is permanently suspended' do
@ -86,8 +84,11 @@ RSpec.describe FollowerAccountsController do
it 'returns followers' do it 'returns followers' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body['totalItems']).to eq 2 expect(response.parsed_body)
expect(body['partOf']).to be_blank .to include(
totalItems: eq(2)
)
.and not_include(:partOf)
end end
context 'when account hides their network' do context 'when account hides their network' do
@ -95,15 +96,17 @@ RSpec.describe FollowerAccountsController do
alice.update(hide_collections: true) alice.update(hide_collections: true)
end end
it 'returns followers count' do it 'returns followers count but not any items' do
expect(body['totalItems']).to eq 2 expect(response.parsed_body)
end .to include(
totalItems: eq(2)
it 'does not return items' do )
expect(body['items']).to be_blank .and not_include(
expect(body['orderedItems']).to be_blank :items,
expect(body['first']).to be_blank :orderedItems,
expect(body['last']).to be_blank :first,
:last
)
end end
end end

View File

@ -39,8 +39,6 @@ RSpec.describe FollowingAccountsController do
end end
context 'when format is json' do context 'when format is json' do
subject(:body) { response.parsed_body }
let(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } } let(:response) { get :index, params: { account_username: alice.username, page: page, format: :json } }
context 'with page' do context 'with page' do
@ -48,15 +46,15 @@ RSpec.describe FollowingAccountsController do
it 'returns followers' do it 'returns followers' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
orderedItems: contain_exactly( orderedItems: contain_exactly(
include(follow_of_bob.target_account.username), include(follow_of_bob.target_account.username),
include(follow_of_chris.target_account.username) include(follow_of_chris.target_account.username)
) ),
totalItems: eq(2),
partOf: be_present
) )
expect(body['totalItems']).to eq 2
expect(body['partOf']).to be_present
end end
context 'when account is permanently suspended' do context 'when account is permanently suspended' do
@ -86,8 +84,11 @@ RSpec.describe FollowingAccountsController do
it 'returns followers' do it 'returns followers' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body['totalItems']).to eq 2 expect(response.parsed_body)
expect(body['partOf']).to be_blank .to include(
totalItems: eq(2)
)
.and not_include(:partOf)
end end
context 'when account hides their network' do context 'when account hides their network' do
@ -95,15 +96,17 @@ RSpec.describe FollowingAccountsController do
alice.update(hide_collections: true) alice.update(hide_collections: true)
end end
it 'returns followers count' do it 'returns followers count but not any items' do
expect(body['totalItems']).to eq 2 expect(response.parsed_body)
end .to include(
totalItems: eq(2)
it 'does not return items' do )
expect(body['items']).to be_blank .and not_include(
expect(body['orderedItems']).to be_blank :items,
expect(body['first']).to be_blank :orderedItems,
expect(body['last']).to be_blank :first,
:last
)
end end
end end

View File

@ -81,7 +81,7 @@ RSpec.describe StatusesController do
'Content-Type' => include('application/activity+json'), 'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') } 'Link' => satisfy { |header| header.to_s.include?('activity+json') }
) )
expect(body_as_json) expect(response.parsed_body)
.to include(content: include(status.text)) .to include(content: include(status.text))
end end
end end
@ -186,7 +186,7 @@ RSpec.describe StatusesController do
'Content-Type' => include('application/activity+json'), 'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') } 'Link' => satisfy { |header| header.to_s.include?('activity+json') }
) )
expect(body_as_json) expect(response.parsed_body)
.to include(content: include(status.text)) .to include(content: include(status.text))
end end
end end
@ -230,7 +230,7 @@ RSpec.describe StatusesController do
'Content-Type' => include('application/activity+json'), 'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') } 'Link' => satisfy { |header| header.to_s.include?('activity+json') }
) )
expect(body_as_json) expect(response.parsed_body)
.to include(content: include(status.text)) .to include(content: include(status.text))
end end
end end
@ -296,7 +296,7 @@ RSpec.describe StatusesController do
'Content-Type' => include('application/activity+json'), 'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') } 'Link' => satisfy { |header| header.to_s.include?('activity+json') }
) )
expect(body_as_json) expect(response.parsed_body)
.to include(content: include(status.text)) .to include(content: include(status.text))
end end
end end
@ -387,7 +387,7 @@ RSpec.describe StatusesController do
'Content-Type' => include('application/activity+json'), 'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') } 'Link' => satisfy { |header| header.to_s.include?('activity+json') }
) )
expect(body_as_json) expect(response.parsed_body)
.to include(content: include(status.text)) .to include(content: include(status.text))
end end
end end
@ -431,7 +431,7 @@ RSpec.describe StatusesController do
'Link' => satisfy { |header| header.to_s.include?('activity+json') } 'Link' => satisfy { |header| header.to_s.include?('activity+json') }
) )
expect(body_as_json) expect(response.parsed_body)
.to include(content: include(status.text)) .to include(content: include(status.text))
end end
end end
@ -497,7 +497,7 @@ RSpec.describe StatusesController do
'Content-Type' => include('application/activity+json'), 'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') } 'Link' => satisfy { |header| header.to_s.include?('activity+json') }
) )
expect(body_as_json) expect(response.parsed_body)
.to include(content: include(status.text)) .to include(content: include(status.text))
end end
end end

View File

@ -134,7 +134,7 @@ RSpec.describe 'Accounts show response' do
media_type: eq('application/activity+json') media_type: eq('application/activity+json')
) )
expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary) expect(response.parsed_body).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
end end
context 'with authorized fetch mode' do context 'with authorized fetch mode' do
@ -163,7 +163,7 @@ RSpec.describe 'Accounts show response' do
expect(response.headers['Cache-Control']).to include 'private' expect(response.headers['Cache-Control']).to include 'private'
expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary) expect(response.parsed_body).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
end end
end end
@ -182,7 +182,7 @@ RSpec.describe 'Accounts show response' do
media_type: eq('application/activity+json') media_type: eq('application/activity+json')
) )
expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary) expect(response.parsed_body).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
end end
context 'with authorized fetch mode' do context 'with authorized fetch mode' do
@ -198,7 +198,7 @@ RSpec.describe 'Accounts show response' do
expect(response.headers['Cache-Control']).to include 'private' expect(response.headers['Cache-Control']).to include 'private'
expect(response.headers['Vary']).to include 'Signature' expect(response.headers['Vary']).to include 'Signature'
expect(body_as_json).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary) expect(response.parsed_body).to include(:id, :type, :preferredUsername, :inbox, :publicKey, :name, :summary)
end end
end end
end end

View File

@ -20,7 +20,7 @@ RSpec.describe 'credentials API' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json).to include({ expect(response.parsed_body).to include({
source: hash_including({ source: hash_including({
discoverable: false, discoverable: false,
indexable: false, indexable: false,
@ -37,7 +37,7 @@ RSpec.describe 'credentials API' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to include({ expect(response.parsed_body).to include({
locked: true, locked: true,
}) })
end end
@ -93,7 +93,7 @@ RSpec.describe 'credentials API' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json).to include({ expect(response.parsed_body).to include({
source: hash_including({ source: hash_including({
discoverable: true, discoverable: true,
indexable: true, indexable: true,

View File

@ -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 } 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 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 end
end end

View File

@ -23,7 +23,7 @@ RSpec.describe 'account featured tags API' do
subject subject
expect(response).to have_http_status(200) 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', name: 'bar',
url: "https://cb6e6126.ngrok.io/@#{account.username}/tagged/bar", url: "https://cb6e6126.ngrok.io/@#{account.username}/tagged/bar",
}), a_hash_including({ }), a_hash_including({
@ -37,7 +37,7 @@ RSpec.describe 'account featured tags API' do
subject subject
expect(response).to have_http_status(200) 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', name: 'bar',
url: "https://cb6e6126.ngrok.io/@#{account.pretty_acct}/tagged/bar", url: "https://cb6e6126.ngrok.io/@#{account.pretty_acct}/tagged/bar",
}), a_hash_including({ }), a_hash_including({

View File

@ -21,8 +21,8 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to eq 2 expect(response.parsed_body.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[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
end end
it 'does not return blocked users', :aggregate_failures do 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 get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to eq 1 expect(response.parsed_body.size).to eq 1
expect(body_as_json[0][:id]).to eq alice.id.to_s expect(response.parsed_body[0][:id]).to eq alice.id.to_s
end end
context 'when requesting user is blocked' do context 'when requesting user is blocked' do
@ -41,7 +41,7 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
it 'hides results' do it 'hides results' do
get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers 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
end end
@ -52,8 +52,8 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
account.mute!(bob) account.mute!(bob)
get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers
expect(body_as_json.size).to eq 2 expect(response.parsed_body.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[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
end end
end end
end end

View File

@ -21,8 +21,8 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to eq 2 expect(response.parsed_body.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[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
end end
it 'does not return blocked users', :aggregate_failures do 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 get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to eq 1 expect(response.parsed_body.size).to eq 1
expect(body_as_json[0][:id]).to eq alice.id.to_s expect(response.parsed_body[0][:id]).to eq alice.id.to_s
end end
context 'when requesting user is blocked' do context 'when requesting user is blocked' do
@ -41,7 +41,7 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
it 'hides results' do it 'hides results' do
get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers 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
end end
@ -52,8 +52,8 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
account.mute!(bob) account.mute!(bob)
get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers
expect(body_as_json.size).to eq 2 expect(response.parsed_body.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[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
end end
end end
end end

View File

@ -29,7 +29,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_an(Enumerable) .to be_an(Enumerable)
.and contain_exactly( .and contain_exactly(
include( include(
@ -50,7 +50,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_an(Enumerable) .to be_an(Enumerable)
.and have_attributes( .and have_attributes(
size: 2 size: 2
@ -70,7 +70,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_an(Enumerable) .to be_an(Enumerable)
.and have_attributes( .and have_attributes(
size: 3 size: 3
@ -89,7 +89,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
it 'removes duplicate account IDs from params' do it 'removes duplicate account IDs from params' do
subject subject
expect(body_as_json) expect(response.parsed_body)
.to be_an(Enumerable) .to be_an(Enumerable)
.and have_attributes( .and have_attributes(
size: 2 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 it 'returns JSON with correct data on previously cached requests' do
# Initial request including multiple accounts in params # Initial request including multiple accounts in params
get '/api/v1/accounts/relationships', headers: headers, params: { id: [simon.id, lewis.id] } 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) .to have_attributes(size: 2)
# Subsequent request with different id, should override cache from first request # 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) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_an(Enumerable) .to be_an(Enumerable)
.and have_attributes( .and have_attributes(
size: 1 size: 1
@ -172,7 +172,7 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_an(Enumerable) .to be_an(Enumerable)
.and contain_exactly( .and contain_exactly(
include( include(

View File

@ -41,7 +41,7 @@ RSpec.describe 'API V1 Accounts Statuses' do
it 'returns posts along with self replies', :aggregate_failures do it 'returns posts along with self replies', :aggregate_failures do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to have_attributes(size: 2) .to have_attributes(size: 2)
.and contain_exactly( .and contain_exactly(
include(id: status.id.to_s), include(id: status.id.to_s),
@ -102,7 +102,7 @@ RSpec.describe 'API V1 Accounts Statuses' do
it 'lists the public status only' do it 'lists the public status only' do
get "/api/v1/accounts/#{account.id}/statuses", params: { pinned: true }, headers: headers get "/api/v1/accounts/#{account.id}/statuses", params: { pinned: true }, headers: headers
expect(body_as_json) expect(response.parsed_body)
.to contain_exactly( .to contain_exactly(
a_hash_including(id: status.id.to_s) 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 it 'lists both the public and the private statuses' do
get "/api/v1/accounts/#{account.id}/statuses", params: { pinned: true }, headers: headers get "/api/v1/accounts/#{account.id}/statuses", params: { pinned: true }, headers: headers
expect(body_as_json) expect(response.parsed_body)
.to contain_exactly( .to contain_exactly(
a_hash_including(id: status.id.to_s), a_hash_including(id: status.id.to_s),
a_hash_including(id: private_status.id.to_s) a_hash_including(id: private_status.id.to_s)

View File

@ -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] } get '/api/v1/accounts', headers: headers, params: { id: [account.id, other_account.id, 123_123] }
expect(response).to have_http_status(200) 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: account.id.to_s),
hash_including(id: other_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}" get "/api/v1/accounts/#{account.id}"
expect(response).to have_http_status(200) 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
end end
@ -41,7 +41,7 @@ RSpec.describe '/api/v1/accounts' do
get '/api/v1/accounts/1' get '/api/v1/accounts/1'
expect(response).to have_http_status(404) 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
end end
@ -57,7 +57,7 @@ RSpec.describe '/api/v1/accounts' do
subject subject
expect(response).to have_http_status(200) 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
it_behaves_like 'forbidden for wrong scope', 'write:statuses' it_behaves_like 'forbidden for wrong scope', 'write:statuses'
@ -80,7 +80,7 @@ RSpec.describe '/api/v1/accounts' do
subject subject
expect(response).to have_http_status(200) 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') user = User.find_by(email: 'hello@world.tld')
expect(user).to_not be_nil expect(user).to_not be_nil
@ -114,7 +114,7 @@ RSpec.describe '/api/v1/accounts' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
following: true, following: true,
requested: false requested: false
@ -134,7 +134,7 @@ RSpec.describe '/api/v1/accounts' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
following: false, following: false,
requested: true requested: true
@ -157,7 +157,7 @@ RSpec.describe '/api/v1/accounts' do
it 'changes reblogs option' do it 'changes reblogs option' do
post "/api/v1/accounts/#{other_account.id}/follow", headers: headers, params: { reblogs: true } 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, following: true,
showing_reblogs: true, showing_reblogs: true,
notifying: false, notifying: false,
@ -167,7 +167,7 @@ RSpec.describe '/api/v1/accounts' do
it 'changes notify option' do it 'changes notify option' do
post "/api/v1/accounts/#{other_account.id}/follow", headers: headers, params: { notify: true } 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, following: true,
showing_reblogs: false, showing_reblogs: false,
notifying: true, notifying: true,
@ -177,7 +177,7 @@ RSpec.describe '/api/v1/accounts' do
it 'changes languages option' do it 'changes languages option' do
post "/api/v1/accounts/#{other_account.id}/follow", headers: headers, params: { languages: %w(en es) } 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, following: true,
showing_reblogs: false, showing_reblogs: false,
notifying: false, notifying: false,

View File

@ -19,7 +19,7 @@ RSpec.describe 'Accounts' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.pluck(:id)).to match_array(expected_results.map { |a| a.id.to_s }) expect(response.parsed_body.pluck(:id)).to match_array(expected_results.map { |a| a.id.to_s })
end end
end end
@ -93,7 +93,7 @@ RSpec.describe 'Accounts' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
end end
end end
@ -112,7 +112,7 @@ RSpec.describe 'Accounts' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including(id: account.id.to_s, username: account.username, email: account.user.email) a_hash_including(id: account.id.to_s, username: account.username, email: account.user.email)
) )
end end

View File

@ -30,7 +30,7 @@ RSpec.describe 'Canonical Email Blocks' do
it 'returns an empty list' do it 'returns an empty list' do
subject subject
expect(body_as_json).to be_empty expect(response.parsed_body).to be_empty
end end
end end
@ -41,7 +41,7 @@ RSpec.describe 'Canonical Email Blocks' do
it 'returns the correct canonical email hashes' do it 'returns the correct canonical email hashes' do
subject subject
expect(body_as_json.pluck(:canonical_email_hash)).to match_array(expected_email_hashes) expect(response.parsed_body.pluck(:canonical_email_hash)).to match_array(expected_email_hashes)
end end
context 'with limit param' do context 'with limit param' do
@ -50,7 +50,7 @@ RSpec.describe 'Canonical Email Blocks' do
it 'returns only the requested number of canonical email blocks' do it 'returns only the requested number of canonical email blocks' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
end end
@ -62,7 +62,7 @@ RSpec.describe 'Canonical Email Blocks' do
canonical_email_blocks_ids = canonical_email_blocks.pluck(:id).map(&:to_s) canonical_email_blocks_ids = canonical_email_blocks.pluck(:id).map(&:to_s)
expect(body_as_json.pluck(:id)).to match_array(canonical_email_blocks_ids[2..]) expect(response.parsed_body.pluck(:id)).to match_array(canonical_email_blocks_ids[2..])
end end
end end
@ -74,7 +74,7 @@ RSpec.describe 'Canonical Email Blocks' do
canonical_email_blocks_ids = canonical_email_blocks.pluck(:id).map(&:to_s) canonical_email_blocks_ids = canonical_email_blocks.pluck(:id).map(&:to_s)
expect(body_as_json.pluck(:id)).to match_array(canonical_email_blocks_ids[..2]) expect(response.parsed_body.pluck(:id)).to match_array(canonical_email_blocks_ids[..2])
end end
end end
end end
@ -96,7 +96,7 @@ RSpec.describe 'Canonical Email Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
id: eq(canonical_email_block.id.to_s), id: eq(canonical_email_block.id.to_s),
canonical_email_hash: eq(canonical_email_block.canonical_email_hash) canonical_email_hash: eq(canonical_email_block.canonical_email_hash)
@ -142,7 +142,7 @@ RSpec.describe 'Canonical Email Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[0][:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash) expect(response.parsed_body.first[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
end end
end end
@ -151,7 +151,7 @@ RSpec.describe 'Canonical Email Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to be_empty expect(response.parsed_body).to be_empty
end end
end end
end end
@ -173,7 +173,7 @@ RSpec.describe 'Canonical Email Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash) expect(response.parsed_body[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
end end
context 'when the required email param is not provided' do context 'when the required email param is not provided' do
@ -193,7 +193,7 @@ RSpec.describe 'Canonical Email Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:canonical_email_hash]).to eq(params[:canonical_email_hash]) expect(response.parsed_body[:canonical_email_hash]).to eq(params[:canonical_email_hash])
end end
end end
@ -204,7 +204,7 @@ RSpec.describe 'Canonical Email Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash) expect(response.parsed_body[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
end end
end end

View File

@ -27,7 +27,7 @@ RSpec.describe 'Admin Dimensions' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_an(Array) .to be_an(Array)
end end
end end

View File

@ -30,7 +30,7 @@ RSpec.describe 'Domain Allows' do
it 'returns an empty body' do it 'returns an empty body' do
subject subject
expect(body_as_json).to be_empty expect(response.parsed_body).to be_empty
end end
end end
@ -49,7 +49,7 @@ RSpec.describe 'Domain Allows' do
it 'returns the correct allowed domains' do it 'returns the correct allowed domains' do
subject subject
expect(body_as_json).to match_array(expected_response) expect(response.parsed_body).to match_array(expected_response)
end end
context 'with limit param' do context 'with limit param' do
@ -58,7 +58,7 @@ RSpec.describe 'Domain Allows' do
it 'returns only the requested number of allowed domains' do it 'returns only the requested number of allowed domains' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
end end
end end
@ -79,7 +79,7 @@ RSpec.describe 'Domain Allows' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:domain]).to eq domain_allow.domain expect(response.parsed_body[:domain]).to eq domain_allow.domain
end end
context 'when the requested allowed domain does not exist' do context 'when the requested allowed domain does not exist' do
@ -107,7 +107,7 @@ RSpec.describe 'Domain Allows' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:domain]).to eq 'foo.bar.com' expect(response.parsed_body[:domain]).to eq 'foo.bar.com'
expect(DomainAllow.find_by(domain: 'foo.bar.com')).to be_present expect(DomainAllow.find_by(domain: 'foo.bar.com')).to be_present
end end
end end
@ -140,7 +140,7 @@ RSpec.describe 'Domain Allows' do
it 'returns the existing allowed domain name' do it 'returns the existing allowed domain name' do
subject subject
expect(body_as_json[:domain]).to eq(params[:domain]) expect(response.parsed_body[:domain]).to eq(params[:domain])
end end
end end
end end

View File

@ -30,7 +30,7 @@ RSpec.describe 'Domain Blocks' do
it 'returns an empty list' do it 'returns an empty list' do
subject subject
expect(body_as_json).to be_empty expect(response.parsed_body).to be_empty
end end
end end
@ -64,7 +64,7 @@ RSpec.describe 'Domain Blocks' do
it 'returns the expected domain blocks' do it 'returns the expected domain blocks' do
subject subject
expect(body_as_json).to match_array(expected_responde) expect(response.parsed_body).to match_array(expected_responde)
end end
context 'with limit param' do context 'with limit param' do
@ -73,7 +73,7 @@ RSpec.describe 'Domain Blocks' do
it 'returns only the requested number of domain blocks' do it 'returns only the requested number of domain blocks' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
end end
end end
@ -94,19 +94,17 @@ RSpec.describe 'Domain Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match( expect(response.parsed_body).to match(
{ id: domain_block.id.to_s,
id: domain_block.id.to_s, domain: domain_block.domain,
domain: domain_block.domain, digest: domain_block.domain_digest,
digest: domain_block.domain_digest, created_at: domain_block.created_at.strftime('%Y-%m-%dT%H:%M:%S.%LZ'),
created_at: domain_block.created_at.strftime('%Y-%m-%dT%H:%M:%S.%LZ'), severity: domain_block.severity.to_s,
severity: domain_block.severity.to_s, reject_media: domain_block.reject_media,
reject_media: domain_block.reject_media, reject_reports: domain_block.reject_reports,
reject_reports: domain_block.reject_reports, private_comment: domain_block.private_comment,
private_comment: domain_block.private_comment, public_comment: domain_block.public_comment,
public_comment: domain_block.public_comment, obfuscate: domain_block.obfuscate
obfuscate: domain_block.obfuscate,
}
) )
end end
@ -134,7 +132,7 @@ RSpec.describe 'Domain Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match a_hash_including( expect(response.parsed_body).to match a_hash_including(
{ {
domain: 'foo.bar.com', domain: 'foo.bar.com',
severity: 'silence', severity: 'silence',
@ -155,7 +153,7 @@ RSpec.describe 'Domain Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match a_hash_including( expect(response.parsed_body).to match a_hash_including(
{ {
domain: 'foo.bar.com', domain: 'foo.bar.com',
severity: 'suspend', severity: 'suspend',
@ -175,7 +173,7 @@ RSpec.describe 'Domain Blocks' do
subject subject
expect(response).to have_http_status(422) expect(response).to have_http_status(422)
expect(body_as_json[:existing_domain_block][:domain]).to eq('foo.bar.com') expect(response.parsed_body[:existing_domain_block][:domain]).to eq('foo.bar.com')
end end
end end
@ -188,7 +186,7 @@ RSpec.describe 'Domain Blocks' do
subject subject
expect(response).to have_http_status(422) expect(response).to have_http_status(422)
expect(body_as_json[:existing_domain_block][:domain]).to eq('bar.com') expect(response.parsed_body[:existing_domain_block][:domain]).to eq('bar.com')
end end
end end
@ -219,7 +217,7 @@ RSpec.describe 'Domain Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match a_hash_including( expect(response.parsed_body).to match a_hash_including(
{ {
id: domain_block.id.to_s, id: domain_block.id.to_s,
domain: domain_block.domain, domain: domain_block.domain,

View File

@ -31,7 +31,7 @@ RSpec.describe 'Email Domain Blocks' do
it 'returns an empty list' do it 'returns an empty list' do
subject subject
expect(body_as_json).to be_empty expect(response.parsed_body).to be_empty
end end
end end
@ -42,7 +42,7 @@ RSpec.describe 'Email Domain Blocks' do
it 'return the correct blocked email domains' do it 'return the correct blocked email domains' do
subject subject
expect(body_as_json.pluck(:domain)).to match_array(blocked_email_domains) expect(response.parsed_body.pluck(:domain)).to match_array(blocked_email_domains)
end end
context 'with limit param' do context 'with limit param' do
@ -51,7 +51,7 @@ RSpec.describe 'Email Domain Blocks' do
it 'returns only the requested number of email domain blocks' do it 'returns only the requested number of email domain blocks' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
end end
@ -63,7 +63,7 @@ RSpec.describe 'Email Domain Blocks' do
email_domain_blocks_ids = email_domain_blocks.pluck(:id).map(&:to_s) email_domain_blocks_ids = email_domain_blocks.pluck(:id).map(&:to_s)
expect(body_as_json.pluck(:id)).to match_array(email_domain_blocks_ids[2..]) expect(response.parsed_body.pluck(:id)).to match_array(email_domain_blocks_ids[2..])
end end
end end
@ -75,7 +75,7 @@ RSpec.describe 'Email Domain Blocks' do
email_domain_blocks_ids = email_domain_blocks.pluck(:id).map(&:to_s) email_domain_blocks_ids = email_domain_blocks.pluck(:id).map(&:to_s)
expect(body_as_json.pluck(:id)).to match_array(email_domain_blocks_ids[..2]) expect(response.parsed_body.pluck(:id)).to match_array(email_domain_blocks_ids[..2])
end end
end end
end end
@ -97,7 +97,7 @@ RSpec.describe 'Email Domain Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:domain]).to eq(email_domain_block.domain) expect(response.parsed_body[:domain]).to eq(email_domain_block.domain)
end end
end end
@ -125,7 +125,7 @@ RSpec.describe 'Email Domain Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:domain]).to eq(params[:domain]) expect(response.parsed_body[:domain]).to eq(params[:domain])
end end
context 'when domain param is not provided' do context 'when domain param is not provided' do
@ -176,7 +176,7 @@ RSpec.describe 'Email Domain Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to be_empty expect(response.parsed_body).to be_empty
expect(EmailDomainBlock.find_by(id: email_domain_block.id)).to be_nil expect(EmailDomainBlock.find_by(id: email_domain_block.id)).to be_nil
end end

View File

@ -30,7 +30,7 @@ RSpec.describe 'IP Blocks' do
it 'returns an empty body' do it 'returns an empty body' do
subject subject
expect(body_as_json).to be_empty expect(response.parsed_body).to be_empty
end end
end end
@ -58,7 +58,7 @@ RSpec.describe 'IP Blocks' do
it 'returns the correct blocked ips' do it 'returns the correct blocked ips' do
subject subject
expect(body_as_json).to match_array(expected_response) expect(response.parsed_body).to match_array(expected_response)
end end
context 'with limit param' do context 'with limit param' do
@ -67,7 +67,7 @@ RSpec.describe 'IP Blocks' do
it 'returns only the requested number of ip blocks' do it 'returns only the requested number of ip blocks' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
end end
end end
@ -89,7 +89,7 @@ RSpec.describe 'IP Blocks' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
ip: eq("#{ip_block.ip}/#{ip_block.ip.prefix}"), ip: eq("#{ip_block.ip}/#{ip_block.ip.prefix}"),
severity: eq(ip_block.severity.to_s) severity: eq(ip_block.severity.to_s)
@ -120,7 +120,7 @@ RSpec.describe 'IP Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
ip: eq("#{params[:ip]}/32"), ip: eq("#{params[:ip]}/32"),
severity: eq(params[:severity]), severity: eq(params[:severity]),
@ -185,7 +185,7 @@ RSpec.describe 'IP Blocks' do
.and change_comment_value .and change_comment_value
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match(hash_including({ expect(response.parsed_body).to match(hash_including({
ip: "#{ip_block.ip}/#{ip_block.ip.prefix}", ip: "#{ip_block.ip}/#{ip_block.ip.prefix}",
severity: 'sign_up_requires_approval', severity: 'sign_up_requires_approval',
comment: 'Decreasing severity', comment: 'Decreasing severity',
@ -220,7 +220,7 @@ RSpec.describe 'IP Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to be_empty expect(response.parsed_body).to be_empty
expect(IpBlock.find_by(id: ip_block.id)).to be_nil expect(IpBlock.find_by(id: ip_block.id)).to be_nil
end end

View File

@ -44,7 +44,7 @@ RSpec.describe 'Admin Measures' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_an(Array) .to be_an(Array)
end end
end end

View File

@ -29,7 +29,7 @@ RSpec.describe 'Reports' do
it 'returns an empty list' do it 'returns an empty list' do
subject subject
expect(body_as_json).to be_empty expect(response.parsed_body).to be_empty
end end
end end
@ -64,7 +64,7 @@ RSpec.describe 'Reports' do
it 'returns all unresolved reports' do it 'returns all unresolved reports' do
subject subject
expect(body_as_json).to match_array(expected_response) expect(response.parsed_body).to match_array(expected_response)
end end
context 'with resolved param' do context 'with resolved param' do
@ -74,7 +74,7 @@ RSpec.describe 'Reports' do
it 'returns only the resolved reports' do it 'returns only the resolved reports' do
subject subject
expect(body_as_json).to match_array(expected_response) expect(response.parsed_body).to match_array(expected_response)
end end
end end
@ -85,7 +85,7 @@ RSpec.describe 'Reports' do
it 'returns all unresolved reports filed by the specified account' do it 'returns all unresolved reports filed by the specified account' do
subject subject
expect(body_as_json).to match_array(expected_response) expect(response.parsed_body).to match_array(expected_response)
end end
end end
@ -96,7 +96,7 @@ RSpec.describe 'Reports' do
it 'returns all unresolved reports targeting the specified account' do it 'returns all unresolved reports targeting the specified account' do
subject subject
expect(body_as_json).to match_array(expected_response) expect(response.parsed_body).to match_array(expected_response)
end end
end end
@ -106,7 +106,7 @@ RSpec.describe 'Reports' do
it 'returns only the requested number of reports' do it 'returns only the requested number of reports' do
subject subject
expect(body_as_json.size).to eq(1) expect(response.parsed_body.size).to eq(1)
end end
end end
end end
@ -126,7 +126,7 @@ RSpec.describe 'Reports' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to include( expect(response.parsed_body).to include(
{ {
id: report.id.to_s, id: report.id.to_s,
action_taken: report.action_taken?, action_taken: report.action_taken?,
@ -159,7 +159,7 @@ RSpec.describe 'Reports' do
report.reload report.reload
expect(body_as_json).to include( expect(response.parsed_body).to include(
{ {
id: report.id.to_s, id: report.id.to_s,
action_taken: report.action_taken?, action_taken: report.action_taken?,

View File

@ -27,7 +27,7 @@ RSpec.describe 'Admin Retention' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_an(Array) .to be_an(Array)
end end
end end

View File

@ -30,7 +30,7 @@ RSpec.describe 'Tags' do
it 'returns an empty list' do it 'returns an empty list' do
subject subject
expect(body_as_json).to be_empty expect(response.parsed_body).to be_empty
end end
end end
@ -47,7 +47,7 @@ RSpec.describe 'Tags' do
it 'returns the expected tags' do it 'returns the expected tags' do
subject subject
tags.each do |tag| tags.each do |tag|
expect(body_as_json.find { |item| item[:id] == tag.id.to_s && item[:name] == tag.name }).to_not be_nil expect(response.parsed_body.find { |item| item[:id] == tag.id.to_s && item[:name] == tag.name }).to_not be_nil
end end
end end
@ -57,7 +57,7 @@ RSpec.describe 'Tags' do
it 'returns only the requested number of tags' do it 'returns only the requested number of tags' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
end end
end end
@ -82,8 +82,8 @@ RSpec.describe 'Tags' do
it 'returns expected tag content' do it 'returns expected tag content' do
subject subject
expect(body_as_json[:id].to_i).to eq(tag.id) expect(response.parsed_body[:id].to_i).to eq(tag.id)
expect(body_as_json[:name]).to eq(tag.name) expect(response.parsed_body[:name]).to eq(tag.name)
end end
context 'when the requested tag does not exist' do context 'when the requested tag does not exist' do
@ -116,8 +116,8 @@ RSpec.describe 'Tags' do
it 'returns updated tag' do it 'returns updated tag' do
subject subject
expect(body_as_json[:id].to_i).to eq(tag.id) expect(response.parsed_body[:id].to_i).to eq(tag.id)
expect(body_as_json[:name]).to eq(tag.name.upcase) expect(response.parsed_body[:name]).to eq(tag.name.upcase)
end end
context 'when the updated display name is invalid' do context 'when the updated display name is invalid' do

View File

@ -44,7 +44,7 @@ RSpec.describe 'Links' do
end end
def expects_correct_link_data def expects_correct_link_data
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including( a_hash_including(
url: preview_card.url, url: preview_card.url,
title: preview_card.title, title: preview_card.title,
@ -98,7 +98,7 @@ RSpec.describe 'Links' do
it 'returns the link data' do it 'returns the link data' do
subject subject
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including( a_hash_including(
url: preview_card.url, url: preview_card.url,
title: preview_card.title, title: preview_card.title,

View File

@ -34,7 +34,7 @@ RSpec.describe 'API V1 Annual Reports' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_present .to be_present
end end
end end

View File

@ -18,7 +18,7 @@ RSpec.describe 'Credentials' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including( a_hash_including(
id: token.application.id.to_s, id: token.application.id.to_s,
name: token.application.name, name: token.application.name,
@ -37,8 +37,8 @@ RSpec.describe 'Credentials' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:client_id]).to_not be_present expect(response.parsed_body[:client_id]).to_not be_present
expect(body_as_json[:client_secret]).to_not be_present expect(response.parsed_body[:client_secret]).to_not be_present
end end
end end
@ -56,7 +56,7 @@ RSpec.describe 'Credentials' do
it 'returns the app information correctly' do it 'returns the app information correctly' do
subject subject
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including( a_hash_including(
id: token.application.id.to_s, id: token.application.id.to_s,
name: token.application.name, name: token.application.name,
@ -95,7 +95,7 @@ RSpec.describe 'Credentials' do
it 'returns the error in the json response' do it 'returns the error in the json response' do
subject subject
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including( a_hash_including(
error: 'The access token was revoked' error: 'The access token was revoked'
) )
@ -117,7 +117,7 @@ RSpec.describe 'Credentials' do
it 'returns the error in the json response' do it 'returns the error in the json response' do
subject subject
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including( a_hash_including(
error: 'The access token is invalid' error: 'The access token is invalid'
) )

View File

@ -35,7 +35,7 @@ RSpec.describe 'Apps' do
expect(app.scopes.to_s).to eq scopes expect(app.scopes.to_s).to eq scopes
expect(app.redirect_uris).to eq redirect_uris expect(app.redirect_uris).to eq redirect_uris
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including( a_hash_including(
id: app.id.to_s, id: app.id.to_s,
client_id: app.uid, client_id: app.uid,
@ -61,7 +61,7 @@ RSpec.describe 'Apps' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(Doorkeeper::Application.find_by(name: client_name)).to be_present expect(Doorkeeper::Application.find_by(name: client_name)).to be_present
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
scopes: Doorkeeper.config.default_scopes.to_a scopes: Doorkeeper.config.default_scopes.to_a
) )
@ -82,7 +82,7 @@ RSpec.describe 'Apps' do
expect(app).to be_present expect(app).to be_present
expect(app.scopes.to_s).to eq 'read' expect(app.scopes.to_s).to eq 'read'
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
scopes: %w(read) scopes: %w(read)
) )
@ -165,7 +165,7 @@ RSpec.describe 'Apps' do
expect(app.redirect_uri).to eq redirect_uris expect(app.redirect_uri).to eq redirect_uris
expect(app.redirect_uris).to eq redirect_uris.split expect(app.redirect_uris).to eq redirect_uris.split
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
redirect_uri: redirect_uris, redirect_uri: redirect_uris,
redirect_uris: redirect_uris.split redirect_uris: redirect_uris.split
@ -187,7 +187,7 @@ RSpec.describe 'Apps' do
expect(app.redirect_uri).to eq redirect_uris.join "\n" expect(app.redirect_uri).to eq redirect_uris.join "\n"
expect(app.redirect_uris).to eq redirect_uris expect(app.redirect_uris).to eq redirect_uris
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
redirect_uri: redirect_uris.join("\n"), redirect_uri: redirect_uris.join("\n"),
redirect_uris: redirect_uris redirect_uris: redirect_uris

View File

@ -26,7 +26,7 @@ RSpec.describe 'Blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match_array(expected_response) expect(response.parsed_body).to match_array(expected_response)
end end
context 'with limit param' do context 'with limit param' do
@ -35,7 +35,7 @@ RSpec.describe 'Blocks' do
it 'returns only the requested number of blocked accounts' do it 'returns only the requested number of blocked accounts' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
it 'sets correct link header pagination' do it 'sets correct link header pagination' do
@ -55,7 +55,7 @@ RSpec.describe 'Blocks' do
it 'queries the blocks in range according to max_id', :aggregate_failures do it 'queries the blocks in range according to max_id', :aggregate_failures do
subject subject
expect(body_as_json) expect(response.parsed_body)
.to contain_exactly(include(id: blocks.first.target_account.id.to_s)) .to contain_exactly(include(id: blocks.first.target_account.id.to_s))
end end
end end
@ -66,7 +66,7 @@ RSpec.describe 'Blocks' do
it 'queries the blocks in range according to since_id', :aggregate_failures do it 'queries the blocks in range according to since_id', :aggregate_failures do
subject subject
expect(body_as_json) expect(response.parsed_body)
.to contain_exactly(include(id: blocks[2].target_account.id.to_s)) .to contain_exactly(include(id: blocks[2].target_account.id.to_s))
end end
end end

View File

@ -33,7 +33,7 @@ RSpec.describe 'Bookmarks' do
it 'returns the bookmarked statuses' do it 'returns the bookmarked statuses' do
subject subject
expect(body_as_json).to match_array(expected_response) expect(response.parsed_body).to match_array(expected_response)
end end
context 'with limit param' do context 'with limit param' do
@ -42,7 +42,7 @@ RSpec.describe 'Bookmarks' do
it 'paginates correctly', :aggregate_failures do it 'paginates correctly', :aggregate_failures do
subject subject
expect(body_as_json.size) expect(response.parsed_body.size)
.to eq(params[:limit]) .to eq(params[:limit])
expect(response) expect(response)

View File

@ -31,8 +31,8 @@ RSpec.describe 'API V1 Conversations' do
it 'returns conversations', :aggregate_failures do it 'returns conversations', :aggregate_failures do
get '/api/v1/conversations', headers: headers get '/api/v1/conversations', headers: headers
expect(body_as_json.size).to eq 2 expect(response.parsed_body.size).to eq 2
expect(body_as_json[0][:accounts].size).to eq 1 expect(response.parsed_body.first[:accounts].size).to eq 1
end end
context 'with since_id' do context 'with since_id' do
@ -40,7 +40,7 @@ RSpec.describe 'API V1 Conversations' do
it 'returns conversations' do it 'returns conversations' do
get '/api/v1/conversations', params: { since_id: Mastodon::Snowflake.id_at(1.hour.ago, with_random: false) }, headers: headers get '/api/v1/conversations', params: { since_id: Mastodon::Snowflake.id_at(1.hour.ago, with_random: false) }, headers: headers
expect(body_as_json.size).to eq 2 expect(response.parsed_body.size).to eq 2
end end
end end
@ -48,7 +48,7 @@ RSpec.describe 'API V1 Conversations' do
it 'returns no conversation' do it 'returns no conversation' do
get '/api/v1/conversations', params: { since_id: Mastodon::Snowflake.id_at(1.hour.from_now, with_random: false) }, headers: headers get '/api/v1/conversations', params: { since_id: Mastodon::Snowflake.id_at(1.hour.from_now, with_random: false) }, headers: headers
expect(body_as_json.size).to eq 0 expect(response.parsed_body.size).to eq 0
end end
end end
end end

View File

@ -19,7 +19,7 @@ RSpec.describe 'Custom Emojis' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_present .to be_present
.and have_attributes( .and have_attributes(
first: include(shortcode: 'coolcat') first: include(shortcode: 'coolcat')
@ -34,7 +34,7 @@ RSpec.describe 'Custom Emojis' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_present .to be_present
.and have_attributes( .and have_attributes(
first: include(shortcode: 'coolcat') first: include(shortcode: 'coolcat')

View File

@ -82,8 +82,8 @@ RSpec.describe 'Directories API' do
get '/api/v1/directory', headers: headers get '/api/v1/directory', headers: headers
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to eq(2) expect(response.parsed_body.size).to eq(2)
expect(body_as_json.pluck(:id)).to contain_exactly(eligible_remote_account.id.to_s, local_discoverable_account.id.to_s) expect(response.parsed_body.pluck(:id)).to contain_exactly(eligible_remote_account.id.to_s, local_discoverable_account.id.to_s)
end end
end end
@ -101,8 +101,8 @@ RSpec.describe 'Directories API' do
get '/api/v1/directory', headers: headers, params: { local: '1' } get '/api/v1/directory', headers: headers, params: { local: '1' }
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to eq(1) expect(response.parsed_body.size).to eq(1)
expect(body_as_json.first[:id]).to include(local_account.id.to_s) expect(response.parsed_body.first[:id]).to include(local_account.id.to_s)
expect(response.body).to_not include(remote_account.id.to_s) expect(response.body).to_not include(remote_account.id.to_s)
end end
end end
@ -115,9 +115,9 @@ RSpec.describe 'Directories API' do
get '/api/v1/directory', headers: headers, params: { order: 'active' } get '/api/v1/directory', headers: headers, params: { order: 'active' }
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to eq(2) expect(response.parsed_body.size).to eq(2)
expect(body_as_json.first[:id]).to include(new_stat.account_id.to_s) expect(response.parsed_body.first[:id]).to include(new_stat.account_id.to_s)
expect(body_as_json.second[:id]).to include(old_stat.account_id.to_s) expect(response.parsed_body.second[:id]).to include(old_stat.account_id.to_s)
end end
end end
@ -130,9 +130,9 @@ RSpec.describe 'Directories API' do
get '/api/v1/directory', headers: headers, params: { order: 'new' } get '/api/v1/directory', headers: headers, params: { order: 'new' }
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to eq(2) expect(response.parsed_body.size).to eq(2)
expect(body_as_json.first[:id]).to include(account_new.id.to_s) expect(response.parsed_body.first[:id]).to include(account_new.id.to_s)
expect(body_as_json.second[:id]).to include(account_old.id.to_s) expect(response.parsed_body.second[:id]).to include(account_old.id.to_s)
end end
end end
end end

View File

@ -26,7 +26,7 @@ RSpec.describe 'Domain blocks' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match_array(blocked_domains) expect(response.parsed_body).to match_array(blocked_domains)
end end
context 'with limit param' do context 'with limit param' do
@ -35,7 +35,7 @@ RSpec.describe 'Domain blocks' do
it 'returns only the requested number of blocked domains' do it 'returns only the requested number of blocked domains' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
end end
end end

View File

@ -111,7 +111,7 @@ RSpec.describe 'Confirmations' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to be false expect(response.parsed_body).to be false
end end
end end
@ -122,7 +122,7 @@ RSpec.describe 'Confirmations' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to be true expect(response.parsed_body).to be true
end end
end end
end end
@ -139,7 +139,7 @@ RSpec.describe 'Confirmations' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to be false expect(response.parsed_body).to be false
end end
end end
@ -150,7 +150,7 @@ RSpec.describe 'Confirmations' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to be true expect(response.parsed_body).to be true
end end
end end
end end

View File

@ -37,7 +37,7 @@ RSpec.describe 'Endorsements' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_present .to be_present
.and have_attributes( .and have_attributes(
first: include(acct: account_pin.target_account.acct) first: include(acct: account_pin.target_account.acct)
@ -52,7 +52,7 @@ RSpec.describe 'Endorsements' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to_not be_present .to_not be_present
end end
end end

View File

@ -33,7 +33,7 @@ RSpec.describe 'Favourites' do
it 'returns the favourites' do it 'returns the favourites' do
subject subject
expect(body_as_json).to match_array(expected_response) expect(response.parsed_body).to match_array(expected_response)
end end
context 'with limit param' do context 'with limit param' do
@ -42,7 +42,7 @@ RSpec.describe 'Favourites' do
it 'returns only the requested number of favourites' do it 'returns only the requested number of favourites' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
it 'sets the correct pagination headers' do it 'sets the correct pagination headers' do

View File

@ -32,7 +32,7 @@ RSpec.describe 'Featured Tags Suggestions API' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to contain_exactly( .to contain_exactly(
include(name: used_tag.name) include(name: used_tag.name)
) )

View File

@ -37,7 +37,7 @@ RSpec.describe 'FeaturedTags' do
it 'returns an empty body' do it 'returns an empty body' do
get '/api/v1/featured_tags', headers: headers get '/api/v1/featured_tags', headers: headers
expect(body_as_json).to be_empty expect(response.parsed_body).to be_empty
end end
end end
@ -47,7 +47,7 @@ RSpec.describe 'FeaturedTags' do
it 'returns only the featured tags belonging to the requesting user' do it 'returns only the featured tags belonging to the requesting user' do
get '/api/v1/featured_tags', headers: headers get '/api/v1/featured_tags', headers: headers
expect(body_as_json.pluck(:id)) expect(response.parsed_body.pluck(:id))
.to match_array( .to match_array(
user_featured_tags.pluck(:id).map(&:to_s) user_featured_tags.pluck(:id).map(&:to_s)
) )
@ -67,7 +67,7 @@ RSpec.describe 'FeaturedTags' do
it 'returns the correct tag name' do it 'returns the correct tag name' do
post '/api/v1/featured_tags', headers: headers, params: params post '/api/v1/featured_tags', headers: headers, params: params
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
name: params[:name] name: params[:name]
) )
@ -141,7 +141,7 @@ RSpec.describe 'FeaturedTags' do
it 'returns an empty body' do it 'returns an empty body' do
delete "/api/v1/featured_tags/#{id}", headers: headers delete "/api/v1/featured_tags/#{id}", headers: headers
expect(body_as_json).to be_empty expect(response.parsed_body).to be_empty
end end
it 'deletes the featured tag', :inline_jobs do it 'deletes the featured tag', :inline_jobs do

View File

@ -15,7 +15,7 @@ RSpec.describe 'API V1 Filters' do
it 'returns http success' do it 'returns http success' do
get '/api/v1/filters', headers: headers get '/api/v1/filters', headers: headers
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to contain_exactly( .to contain_exactly(
include(id: custom_filter_keyword.id.to_s) include(id: custom_filter_keyword.id.to_s)
) )

View File

@ -36,7 +36,7 @@ RSpec.describe 'Follow requests' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match_array(expected_response) expect(response.parsed_body).to match_array(expected_response)
end end
context 'with limit param' do context 'with limit param' do
@ -45,7 +45,7 @@ RSpec.describe 'Follow requests' do
it 'returns only the requested number of follow requests' do it 'returns only the requested number of follow requests' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
end end
end end
@ -66,7 +66,7 @@ RSpec.describe 'Follow requests' do
it 'allows the requesting follower to follow', :aggregate_failures do it 'allows the requesting follower to follow', :aggregate_failures do
expect { subject }.to change { follower.following?(user.account) }.from(false).to(true) expect { subject }.to change { follower.following?(user.account) }.from(false).to(true)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:followed_by]).to be true expect(response.parsed_body[:followed_by]).to be true
end end
end end
@ -88,7 +88,7 @@ RSpec.describe 'Follow requests' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(FollowRequest.where(target_account: user.account, account: follower)).to_not exist expect(FollowRequest.where(target_account: user.account, account: follower)).to_not exist
expect(body_as_json[:followed_by]).to be false expect(response.parsed_body[:followed_by]).to be false
end end
end end
end end

View File

@ -37,7 +37,7 @@ RSpec.describe 'Followed tags' do
it 'returns the followed tags correctly' do it 'returns the followed tags correctly' do
subject subject
expect(body_as_json).to match_array(expected_response) expect(response.parsed_body).to match_array(expected_response)
end end
context 'with limit param' do context 'with limit param' do
@ -46,7 +46,7 @@ RSpec.describe 'Followed tags' do
it 'returns only the requested number of follow tags' do it 'returns only the requested number of follow tags' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
it 'sets the correct pagination headers' do it 'sets the correct pagination headers' do

View File

@ -15,7 +15,7 @@ RSpec.describe 'Instances' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_present .to be_present
.and include(title: 'Mastodon') .and include(title: 'Mastodon')
end end
@ -28,7 +28,7 @@ RSpec.describe 'Instances' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_present .to be_present
.and include(title: 'Mastodon') .and include(title: 'Mastodon')
end end

View File

@ -13,7 +13,7 @@ RSpec.describe 'Activity' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_present .to be_present
.and(be_an(Array)) .and(be_an(Array))
.and(have_attributes(size: Api::V1::Instances::ActivityController::WEEKS_OF_ACTIVITY)) .and(have_attributes(size: Api::V1::Instances::ActivityController::WEEKS_OF_ACTIVITY))

View File

@ -17,7 +17,7 @@ RSpec.describe 'Domain Blocks' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_present .to be_present
.and(be_an(Array)) .and(be_an(Array))
.and(have_attributes(size: 1)) .and(have_attributes(size: 1))

View File

@ -10,7 +10,7 @@ RSpec.describe 'Extended Descriptions' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_present .to be_present
.and include(:content) .and include(:content)
end end

View File

@ -13,7 +13,7 @@ RSpec.describe 'Languages' do
end end
it 'returns the supported languages' do it 'returns the supported languages' do
expect(body_as_json.pluck(:code)).to match_array LanguagesHelper::SUPPORTED_LOCALES.keys.map(&:to_s) expect(response.parsed_body.pluck(:code)).to match_array LanguagesHelper::SUPPORTED_LOCALES.keys.map(&:to_s)
end end
end end
end end

View File

@ -13,7 +13,7 @@ RSpec.describe 'Peers' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_an(Array) .to be_an(Array)
end end
end end

View File

@ -10,7 +10,7 @@ RSpec.describe 'Privacy Policy' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_present .to be_present
.and include(:content) .and include(:content)
end end

View File

@ -10,7 +10,7 @@ RSpec.describe 'Rules' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_an(Array) .to be_an(Array)
end end
end end

View File

@ -11,7 +11,7 @@ RSpec.describe 'Translation Languages' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to eq({}) .to eq({})
end end
end end
@ -25,7 +25,7 @@ RSpec.describe 'Translation Languages' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to match({ und: %w(en de), en: ['de'] }) .to match({ und: %w(en de), en: ['de'] })
end end

View File

@ -34,7 +34,7 @@ RSpec.describe 'Accounts' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match_array(expected_response) expect(response.parsed_body).to match_array(expected_response)
end end
context 'with limit param' do context 'with limit param' do
@ -43,7 +43,7 @@ RSpec.describe 'Accounts' do
it 'returns only the requested number of accounts' do it 'returns only the requested number of accounts' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
end end
end end

View File

@ -43,7 +43,7 @@ RSpec.describe 'Lists' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match_array(expected_response) expect(response.parsed_body).to match_array(expected_response)
end end
end end
@ -60,7 +60,7 @@ RSpec.describe 'Lists' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match({ expect(response.parsed_body).to match({
id: list.id.to_s, id: list.id.to_s,
title: list.title, title: list.title,
replies_policy: list.replies_policy, replies_policy: list.replies_policy,
@ -100,7 +100,7 @@ RSpec.describe 'Lists' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match(a_hash_including(title: 'my list', replies_policy: 'none', exclusive: true)) expect(response.parsed_body).to match(a_hash_including(title: 'my list', replies_policy: 'none', exclusive: true))
expect(List.where(account: user.account).count).to eq(1) expect(List.where(account: user.account).count).to eq(1)
end end
@ -144,7 +144,7 @@ RSpec.describe 'Lists' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
list.reload list.reload
expect(body_as_json).to match({ expect(response.parsed_body).to match({
id: list.id.to_s, id: list.id.to_s,
title: list.title, title: list.title,
replies_policy: list.replies_policy, replies_policy: list.replies_policy,

View File

@ -18,7 +18,7 @@ RSpec.describe 'API Markers' do
it 'returns markers', :aggregate_failures do it 'returns markers', :aggregate_failures do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
home: include(last_read_id: '123'), home: include(last_read_id: '123'),
notifications: include(last_read_id: '456') notifications: include(last_read_id: '456')
@ -61,7 +61,7 @@ RSpec.describe 'API Markers' do
it 'returns error json' do it 'returns error json' do
expect(response) expect(response)
.to have_http_status(409) .to have_http_status(409)
expect(body_as_json) expect(response.parsed_body)
.to include(error: /Conflict during update/) .to include(error: /Conflict during update/)
end end
end end

View File

@ -26,7 +26,7 @@ RSpec.describe 'Media' do
it 'returns the media information' do it 'returns the media information' do
subject subject
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including( a_hash_including(
id: media.id.to_s, id: media.id.to_s,
description: media.description, description: media.description,
@ -83,7 +83,7 @@ RSpec.describe 'Media' do
expect(MediaAttachment.first).to be_present expect(MediaAttachment.first).to be_present
expect(MediaAttachment.first).to have_attached_file(:file) expect(MediaAttachment.first).to have_attached_file(:file)
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including(id: MediaAttachment.first.id.to_s, description: params[:description], type: media_type) a_hash_including(id: MediaAttachment.first.id.to_s, description: params[:description], type: media_type)
) )
end end

View File

@ -29,7 +29,7 @@ RSpec.describe 'Mutes' do
muted_accounts = mutes.map(&:target_account) muted_accounts = mutes.map(&:target_account)
expect(body_as_json.pluck(:id)).to match_array(muted_accounts.map { |account| account.id.to_s }) expect(response.parsed_body.pluck(:id)).to match_array(muted_accounts.map { |account| account.id.to_s })
end end
context 'with limit param' do context 'with limit param' do
@ -38,7 +38,7 @@ RSpec.describe 'Mutes' do
it 'returns only the requested number of muted accounts' do it 'returns only the requested number of muted accounts' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
it 'sets the correct pagination headers', :aggregate_failures do it 'sets the correct pagination headers', :aggregate_failures do
@ -58,7 +58,7 @@ RSpec.describe 'Mutes' do
it 'queries mutes in range according to max_id', :aggregate_failures do it 'queries mutes in range according to max_id', :aggregate_failures do
subject subject
expect(body_as_json) expect(response.parsed_body)
.to contain_exactly(include(id: mutes.first.target_account_id.to_s)) .to contain_exactly(include(id: mutes.first.target_account_id.to_s))
end end
end end
@ -69,7 +69,7 @@ RSpec.describe 'Mutes' do
it 'queries mutes in range according to since_id', :aggregate_failures do it 'queries mutes in range according to since_id', :aggregate_failures do
subject subject
expect(body_as_json) expect(response.parsed_body)
.to contain_exactly(include(id: mutes[1].target_account_id.to_s)) .to contain_exactly(include(id: mutes[1].target_account_id.to_s))
end end
end end

View File

@ -26,7 +26,7 @@ RSpec.describe 'Policies' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to include( expect(response.parsed_body).to include(
filter_not_following: false, filter_not_following: false,
filter_not_followers: false, filter_not_followers: false,
filter_new_accounts: false, filter_new_accounts: false,
@ -54,7 +54,7 @@ RSpec.describe 'Policies' do
.to change { NotificationPolicy.find_or_initialize_by(account: user.account).for_not_following.to_sym }.from(:accept).to(:filter) .to change { NotificationPolicy.find_or_initialize_by(account: user.account).for_not_following.to_sym }.from(:accept).to(:filter)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to include( expect(response.parsed_body).to include(
filter_not_following: true, filter_not_following: true,
filter_not_followers: false, filter_not_followers: false,
filter_new_accounts: false, filter_new_accounts: false,

View File

@ -133,7 +133,7 @@ RSpec.describe 'Requests' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match({ merged: true }) expect(response.parsed_body).to match({ merged: true })
end end
end end
@ -146,7 +146,7 @@ RSpec.describe 'Requests' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match({ merged: false }) expect(response.parsed_body).to match({ merged: false })
end end
end end
end end

View File

@ -31,7 +31,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:count]).to eq 5 expect(response.parsed_body[:count]).to eq 5
end end
end end
@ -45,7 +45,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:count]).to eq 2 expect(response.parsed_body[:count]).to eq 2
end end
end end
@ -56,7 +56,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:count]).to eq 4 expect(response.parsed_body[:count]).to eq 4
end end
end end
@ -67,7 +67,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:count]).to eq 2 expect(response.parsed_body[:count]).to eq 2
end end
end end
@ -80,7 +80,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:count]).to eq Api::V1::NotificationsController::DEFAULT_NOTIFICATIONS_COUNT_LIMIT expect(response.parsed_body[:count]).to eq Api::V1::NotificationsController::DEFAULT_NOTIFICATIONS_COUNT_LIMIT
end end
end end
end end
@ -111,9 +111,9 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to eq 5 expect(response.parsed_body.size).to eq 5
expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow') expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow')
expect(body_as_json.any? { |x| x[:filtered] }).to be false expect(response.parsed_body.any? { |x| x[:filtered] }).to be false
end end
end end
@ -124,9 +124,9 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to eq 6 expect(response.parsed_body.size).to eq 6
expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow') expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow')
expect(body_as_json.any? { |x| x[:filtered] }).to be true expect(response.parsed_body.any? { |x| x[:filtered] }).to be true
end end
end end
@ -141,7 +141,7 @@ RSpec.describe 'Notifications' do
end end
def body_json_account_ids def body_json_account_ids
body_as_json.map { |x| x[:account][:id] } response.parsed_body.map { |x| x[:account][:id] }
end end
end end
@ -152,7 +152,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to eq 0 expect(response.parsed_body.size).to eq 0
end end
end end
@ -163,7 +163,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to_not eq 0 expect(response.parsed_body.size).to_not eq 0
expect(body_json_types.uniq).to_not include 'mention' expect(body_json_types.uniq).to_not include 'mention'
end end
end end
@ -187,7 +187,7 @@ RSpec.describe 'Notifications' do
notifications = user.account.notifications.browserable.order(id: :asc) notifications = user.account.notifications.browserable.order(id: :asc)
expect(body_as_json.size) expect(response.parsed_body.size)
.to eq(params[:limit]) .to eq(params[:limit])
expect(response) expect(response)
@ -199,7 +199,7 @@ RSpec.describe 'Notifications' do
end end
def body_json_types def body_json_types
body_as_json.pluck(:type) response.parsed_body.pluck(:type)
end end
end end

View File

@ -23,7 +23,7 @@ RSpec.describe 'API Peers Search' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_blank .to be_blank
end end
end end
@ -34,7 +34,7 @@ RSpec.describe 'API Peers Search' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_blank .to be_blank
end end
end end
@ -49,9 +49,9 @@ RSpec.describe 'API Peers Search' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json.size) expect(response.parsed_body.size)
.to eq(1) .to eq(1)
expect(body_as_json.first) expect(response.parsed_body.first)
.to eq(account.domain) .to eq(account.domain)
end end
end end

View File

@ -23,7 +23,7 @@ RSpec.describe 'Polls' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including( a_hash_including(
id: poll.id.to_s, id: poll.id.to_s,
voted: false, voted: false,

View File

@ -34,7 +34,7 @@ RSpec.describe 'Preferences' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_present .to be_present
end end
end end

View File

@ -65,7 +65,7 @@ RSpec.describe 'API V1 Push Subscriptions' do
access_token_id: eq(token.id) access_token_id: eq(token.id)
) )
expect(body_as_json.with_indifferent_access) expect(response.parsed_body.with_indifferent_access)
.to include( .to include(
{ endpoint: create_payload[:subscription][:endpoint], alerts: {}, policy: 'all' } { endpoint: create_payload[:subscription][:endpoint], alerts: {}, policy: 'all' }
) )
@ -124,7 +124,7 @@ RSpec.describe 'API V1 Push Subscriptions' do
) )
end end
expect(body_as_json.with_indifferent_access) expect(response.parsed_body.with_indifferent_access)
.to include( .to include(
endpoint: create_payload[:subscription][:endpoint], endpoint: create_payload[:subscription][:endpoint],
alerts: alerts_payload[:data][:alerts], alerts: alerts_payload[:data][:alerts],

View File

@ -37,7 +37,7 @@ RSpec.describe 'Reports' do
emails = capture_emails { subject } emails = capture_emails { subject }
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including( a_hash_including(
status_ids: [status.id.to_s], status_ids: [status.id.to_s],
category: category, category: category,

View File

@ -46,7 +46,7 @@ RSpec.describe 'Scheduled Statuses' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to_not be_present .to_not be_present
end end
end end
@ -60,7 +60,7 @@ RSpec.describe 'Scheduled Statuses' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_present .to be_present
.and have_attributes( .and have_attributes(
first: include(id: scheduled_status.id.to_s) first: include(id: scheduled_status.id.to_s)

View File

@ -28,7 +28,7 @@ RSpec.describe 'Bookmarks' do
it 'returns json with updated attributes' do it 'returns json with updated attributes' do
subject subject
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, bookmarked: true) a_hash_including(id: status.id.to_s, bookmarked: true)
) )
end end
@ -103,7 +103,7 @@ RSpec.describe 'Bookmarks' do
it 'returns json with updated attributes' do it 'returns json with updated attributes' do
subject subject
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, bookmarked: false) a_hash_including(id: status.id.to_s, bookmarked: false)
) )
end end
@ -127,7 +127,7 @@ RSpec.describe 'Bookmarks' do
it 'returns json with updated attributes' do it 'returns json with updated attributes' do
subject subject
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, bookmarked: false) a_hash_including(id: status.id.to_s, bookmarked: false)
) )
end end

View File

@ -34,9 +34,9 @@ RSpec.describe 'API V1 Statuses Favourited by Accounts' do
next: api_v1_status_favourited_by_index_url(limit: 2, max_id: Favourite.first.id) next: api_v1_status_favourited_by_index_url(limit: 2, max_id: Favourite.first.id)
) )
expect(body_as_json.size) expect(response.parsed_body.size)
.to eq(2) .to eq(2)
expect(body_as_json) expect(response.parsed_body)
.to contain_exactly( .to contain_exactly(
include(id: alice.id.to_s), include(id: alice.id.to_s),
include(id: bob.id.to_s) include(id: bob.id.to_s)
@ -48,9 +48,9 @@ RSpec.describe 'API V1 Statuses Favourited by Accounts' do
subject subject
expect(body_as_json.size) expect(response.parsed_body.size)
.to eq 1 .to eq 1
expect(body_as_json.first[:id]).to eq(alice.id.to_s) expect(response.parsed_body.first[:id]).to eq(alice.id.to_s)
end end
end end
end end

View File

@ -28,7 +28,7 @@ RSpec.describe 'Favourites', :inline_jobs do
it 'returns json with updated attributes' do it 'returns json with updated attributes' do
subject subject
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, favourites_count: 1, favourited: true) a_hash_including(id: status.id.to_s, favourites_count: 1, favourited: true)
) )
end end
@ -95,7 +95,7 @@ RSpec.describe 'Favourites', :inline_jobs do
it 'returns json with updated attributes' do it 'returns json with updated attributes' do
subject subject
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, favourites_count: 0, favourited: false) a_hash_including(id: status.id.to_s, favourites_count: 0, favourited: false)
) )
end end
@ -118,7 +118,7 @@ RSpec.describe 'Favourites', :inline_jobs do
it 'returns json with updated attributes' do it 'returns json with updated attributes' do
subject subject
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, favourites_count: 0, favourited: false) a_hash_including(id: status.id.to_s, favourites_count: 0, favourited: false)
) )
end end

View File

@ -18,7 +18,7 @@ RSpec.describe 'API V1 Statuses Histories' do
it 'returns http success' do it 'returns http success' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to_not be 0 expect(response.parsed_body.size).to_not be 0
end end
end end
end end

View File

@ -28,7 +28,7 @@ RSpec.describe 'Pins' do
it 'return json with updated attributes' do it 'return json with updated attributes' do
subject subject
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, pinned: true) a_hash_including(id: status.id.to_s, pinned: true)
) )
end end
@ -96,7 +96,7 @@ RSpec.describe 'Pins' do
it 'return json with updated attributes' do it 'return json with updated attributes' do
subject subject
expect(body_as_json).to match( expect(response.parsed_body).to match(
a_hash_including(id: status.id.to_s, pinned: false) a_hash_including(id: status.id.to_s, pinned: false)
) )
end end

View File

@ -33,9 +33,9 @@ RSpec.describe 'API V1 Statuses Reblogged by Accounts' do
next: api_v1_status_reblogged_by_index_url(limit: 2, max_id: alice.statuses.first.id) next: api_v1_status_reblogged_by_index_url(limit: 2, max_id: alice.statuses.first.id)
) )
expect(body_as_json.size) expect(response.parsed_body.size)
.to eq(2) .to eq(2)
expect(body_as_json) expect(response.parsed_body)
.to contain_exactly( .to contain_exactly(
include(id: alice.id.to_s), include(id: alice.id.to_s),
include(id: bob.id.to_s) include(id: bob.id.to_s)
@ -47,9 +47,9 @@ RSpec.describe 'API V1 Statuses Reblogged by Accounts' do
subject subject
expect(body_as_json.size) expect(response.parsed_body.size)
.to eq 1 .to eq 1
expect(body_as_json.first[:id]).to eq(alice.id.to_s) expect(response.parsed_body.first[:id]).to eq(alice.id.to_s)
end end
end end
end end

View File

@ -24,7 +24,7 @@ RSpec.describe 'API V1 Statuses Reblogs' do
expect(user.account.reblogged?(status)).to be true expect(user.account.reblogged?(status)).to be true
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
reblog: include( reblog: include(
id: status.id.to_s, id: status.id.to_s,
@ -60,7 +60,7 @@ RSpec.describe 'API V1 Statuses Reblogs' do
expect(user.account.reblogged?(status)).to be false expect(user.account.reblogged?(status)).to be false
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
id: status.id.to_s, id: status.id.to_s,
reblogs_count: 0, reblogs_count: 0,
@ -85,7 +85,7 @@ RSpec.describe 'API V1 Statuses Reblogs' do
expect(user.account.reblogged?(status)).to be false expect(user.account.reblogged?(status)).to be false
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
id: status.id.to_s, id: status.id.to_s,
reblogs_count: 0, reblogs_count: 0,

View File

@ -22,7 +22,7 @@ RSpec.describe 'Sources' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match({ expect(response.parsed_body).to match({
id: status.id.to_s, id: status.id.to_s,
text: status.text, text: status.text,
spoiler_text: status.spoiler_text, spoiler_text: status.spoiler_text,
@ -51,7 +51,7 @@ RSpec.describe 'Sources' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match({ expect(response.parsed_body).to match({
id: status.id.to_s, id: status.id.to_s,
text: status.text, text: status.text,
spoiler_text: status.spoiler_text, spoiler_text: status.spoiler_text,

View File

@ -18,7 +18,7 @@ RSpec.describe '/api/v1/statuses' do
get '/api/v1/statuses', headers: headers, params: { id: [status.id, other_status.id, 123_123] } get '/api/v1/statuses', headers: headers, params: { id: [status.id, other_status.id, 123_123] }
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to contain_exactly( expect(response.parsed_body).to contain_exactly(
hash_including(id: status.id.to_s), hash_including(id: status.id.to_s),
hash_including(id: other_status.id.to_s) hash_including(id: other_status.id.to_s)
) )
@ -52,7 +52,7 @@ RSpec.describe '/api/v1/statuses' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:filtered][0]).to include({ expect(response.parsed_body[:filtered][0]).to include({
filter: a_hash_including({ filter: a_hash_including({
id: user.account.custom_filters.first.id.to_s, id: user.account.custom_filters.first.id.to_s,
title: 'filter1', title: 'filter1',
@ -75,7 +75,7 @@ RSpec.describe '/api/v1/statuses' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:filtered][0]).to include({ expect(response.parsed_body[:filtered][0]).to include({
filter: a_hash_including({ filter: a_hash_including({
id: user.account.custom_filters.first.id.to_s, id: user.account.custom_filters.first.id.to_s,
title: 'filter1', title: 'filter1',
@ -97,7 +97,7 @@ RSpec.describe '/api/v1/statuses' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:reblog][:filtered][0]).to include({ expect(response.parsed_body[:reblog][:filtered][0]).to include({
filter: a_hash_including({ filter: a_hash_including({
id: user.account.custom_filters.first.id.to_s, id: user.account.custom_filters.first.id.to_s,
title: 'filter1', title: 'filter1',
@ -154,7 +154,7 @@ RSpec.describe '/api/v1/statuses' do
subject subject
expect(response).to have_http_status(422) expect(response).to have_http_status(422)
expect(body_as_json[:unexpected_accounts].map { |a| a.slice(:id, :acct) }).to match [{ id: bob.id.to_s, acct: bob.acct }] expect(response.parsed_body[:unexpected_accounts].map { |a| a.slice(:id, :acct) }).to match [{ id: bob.id.to_s, acct: bob.acct }]
end end
end end

View File

@ -32,7 +32,7 @@ RSpec.describe 'Suggestions' do
it 'returns accounts' do it 'returns accounts' do
subject subject
expect(body_as_json) expect(response.parsed_body)
.to contain_exactly(include(id: bob.id.to_s), include(id: jeff.id.to_s)) .to contain_exactly(include(id: bob.id.to_s), include(id: jeff.id.to_s))
end end
@ -42,7 +42,7 @@ RSpec.describe 'Suggestions' do
it 'returns only the requested number of accounts' do it 'returns only the requested number of accounts' do
subject subject
expect(body_as_json.size).to eq 1 expect(response.parsed_body.size).to eq 1
end end
end end

View File

@ -21,7 +21,7 @@ RSpec.describe 'Tags' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:name]).to eq(name) expect(response.parsed_body[:name]).to eq(name)
end end
end end

View File

@ -40,7 +40,7 @@ RSpec.describe 'Home', :inline_jobs do
it 'returns the statuses of followed users' do it 'returns the statuses of followed users' do
subject subject
expect(body_as_json.pluck(:id)).to match_array(home_statuses.map { |status| status.id.to_s }) expect(response.parsed_body.pluck(:id)).to match_array(home_statuses.map { |status| status.id.to_s })
end end
context 'with limit param' do context 'with limit param' do
@ -49,7 +49,7 @@ RSpec.describe 'Home', :inline_jobs do
it 'returns only the requested number of statuses' do it 'returns only the requested number of statuses' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
it 'sets the correct pagination headers', :aggregate_failures do it 'sets the correct pagination headers', :aggregate_failures do

View File

@ -13,7 +13,7 @@ RSpec.describe 'Link' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.pluck(:id)).to match_array(expected_statuses.map { |status| status.id.to_s }) expect(response.parsed_body.pluck(:id)).to match_array(expected_statuses.map { |status| status.id.to_s })
end end
end end
@ -127,7 +127,7 @@ RSpec.describe 'Link' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
it 'sets the correct pagination headers', :aggregate_failures do it 'sets the correct pagination headers', :aggregate_failures do

View File

@ -13,7 +13,7 @@ RSpec.describe 'Public' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.pluck(:id)).to match_array(expected_statuses.map { |status| status.id.to_s }) expect(response.parsed_body.pluck(:id)).to match_array(expected_statuses.map { |status| status.id.to_s })
end end
end end
@ -81,7 +81,7 @@ RSpec.describe 'Public' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
it 'sets the correct pagination headers', :aggregate_failures do it 'sets the correct pagination headers', :aggregate_failures do

View File

@ -19,7 +19,7 @@ RSpec.describe 'Tag' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json.pluck(:id)) expect(response.parsed_body.pluck(:id))
.to match_array(expected_statuses.map { |status| status.id.to_s }) .to match_array(expected_statuses.map { |status| status.id.to_s })
.and not_include(private_status.id) .and not_include(private_status.id)
end end
@ -70,7 +70,7 @@ RSpec.describe 'Tag' do
it 'returns only the requested number of statuses' do it 'returns only the requested number of statuses' do
subject subject
expect(body_as_json.size).to eq(params[:limit]) expect(response.parsed_body.size).to eq(params[:limit])
end end
it 'sets the correct pagination headers', :aggregate_failures do it 'sets the correct pagination headers', :aggregate_failures do

View File

@ -76,7 +76,7 @@ RSpec.describe 'API V2 Admin Accounts' do
end end
def body_json_ids def body_json_ids
body_as_json.map { |a| a[:id].to_i } response.parsed_body.map { |a| a[:id].to_i }
end end
context 'with limit param' do context 'with limit param' do

View File

@ -17,7 +17,7 @@ RSpec.describe 'API V2 Filters Keywords' do
it 'returns http success' do it 'returns http success' do
get "/api/v2/filters/#{filter.id}/keywords", headers: headers get "/api/v2/filters/#{filter.id}/keywords", headers: headers
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to contain_exactly( .to contain_exactly(
include(id: keyword.id.to_s) include(id: keyword.id.to_s)
) )
@ -42,7 +42,7 @@ RSpec.describe 'API V2 Filters Keywords' do
it 'creates a filter', :aggregate_failures do it 'creates a filter', :aggregate_failures do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
keyword: 'magic', keyword: 'magic',
whole_word: false whole_word: false
@ -73,7 +73,7 @@ RSpec.describe 'API V2 Filters Keywords' do
it 'responds with the keyword', :aggregate_failures do it 'responds with the keyword', :aggregate_failures do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
keyword: 'foo', keyword: 'foo',
whole_word: false whole_word: false

View File

@ -17,7 +17,7 @@ RSpec.describe 'API V2 Filters Statuses' do
it 'returns http success' do it 'returns http success' do
get "/api/v2/filters/#{filter.id}/statuses", headers: headers get "/api/v2/filters/#{filter.id}/statuses", headers: headers
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to contain_exactly( .to contain_exactly(
include(id: status_filter.id.to_s) include(id: status_filter.id.to_s)
) )
@ -43,7 +43,7 @@ RSpec.describe 'API V2 Filters Statuses' do
it 'creates a filter', :aggregate_failures do it 'creates a filter', :aggregate_failures do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
status_id: status.id.to_s status_id: status.id.to_s
) )
@ -73,7 +73,7 @@ RSpec.describe 'API V2 Filters Statuses' do
it 'responds with the filter', :aggregate_failures do it 'responds with the filter', :aggregate_failures do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
status_id: status_filter.status.id.to_s status_id: status_filter.status.id.to_s
) )

View File

@ -32,7 +32,7 @@ RSpec.describe 'Filters' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.pluck(:id)).to match_array(filters.map { |filter| filter.id.to_s }) expect(response.parsed_body.pluck(:id)).to match_array(filters.map { |filter| filter.id.to_s })
end end
end end
@ -58,7 +58,7 @@ RSpec.describe 'Filters' do
it 'returns a filter with keywords', :aggregate_failures do it 'returns a filter with keywords', :aggregate_failures do
subject subject
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
title: 'magic', title: 'magic',
filter_action: 'hide', filter_action: 'hide',
@ -127,7 +127,10 @@ RSpec.describe 'Filters' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:id]).to eq(filter.id.to_s) expect(response.parsed_body)
.to include(
id: filter.id.to_s
)
end end
context 'when the filter belongs to someone else' do context 'when the filter belongs to someone else' do

View File

@ -15,7 +15,7 @@ RSpec.describe 'Instances' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_present .to be_present
.and include(title: 'Mastodon') .and include(title: 'Mastodon')
.and include_api_versions .and include_api_versions
@ -30,7 +30,7 @@ RSpec.describe 'Instances' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_present .to be_present
.and include(title: 'Mastodon') .and include(title: 'Mastodon')
.and include_api_versions .and include_api_versions

View File

@ -21,7 +21,7 @@ RSpec.describe 'Media API', :attachment_processing do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to be_a(Hash) .to be_a(Hash)
end end
end end
@ -38,7 +38,7 @@ RSpec.describe 'Media API', :attachment_processing do
expect(response) expect(response)
.to have_http_status(202) .to have_http_status(202)
expect(body_as_json) expect(response.parsed_body)
.to be_a(Hash) .to be_a(Hash)
end end
end end
@ -63,7 +63,7 @@ RSpec.describe 'Media API', :attachment_processing do
expect(response) expect(response)
.to have_http_status(422) .to have_http_status(422)
expect(body_as_json) expect(response.parsed_body)
.to be_a(Hash) .to be_a(Hash)
.and include(error: /File type/) .and include(error: /File type/)
end end
@ -80,7 +80,7 @@ RSpec.describe 'Media API', :attachment_processing do
expect(response) expect(response)
.to have_http_status(500) .to have_http_status(500)
expect(body_as_json) expect(response.parsed_body)
.to be_a(Hash) .to be_a(Hash)
.and include(error: /processing/) .and include(error: /processing/)
end end

View File

@ -26,7 +26,7 @@ RSpec.describe 'Policies' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to include( expect(response.parsed_body).to include(
for_not_following: 'accept', for_not_following: 'accept',
for_not_followers: 'accept', for_not_followers: 'accept',
for_new_accounts: 'accept', for_new_accounts: 'accept',
@ -56,7 +56,7 @@ RSpec.describe 'Policies' do
.and change { NotificationPolicy.find_or_initialize_by(account: user.account).for_limited_accounts.to_sym }.from(:filter).to(:drop) .and change { NotificationPolicy.find_or_initialize_by(account: user.account).for_limited_accounts.to_sym }.from(:filter).to(:drop)
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to include( expect(response.parsed_body).to include(
for_not_following: 'filter', for_not_following: 'filter',
for_not_followers: 'accept', for_not_followers: 'accept',
for_new_accounts: 'accept', for_new_accounts: 'accept',

View File

@ -27,7 +27,7 @@ RSpec.describe 'Search API' do
it 'returns all matching accounts' do it 'returns all matching accounts' do
get '/api/v2/search', headers: headers, params: params get '/api/v2/search', headers: headers, params: params
expect(body_as_json[:accounts].pluck(:id)).to contain_exactly(bob.id.to_s, ana.id.to_s, tom.id.to_s) expect(response.parsed_body[:accounts].pluck(:id)).to contain_exactly(bob.id.to_s, ana.id.to_s, tom.id.to_s)
end end
context 'with truthy `resolve`' do context 'with truthy `resolve`' do
@ -80,7 +80,7 @@ RSpec.describe 'Search API' do
it 'returns only the followed accounts' do it 'returns only the followed accounts' do
get '/api/v2/search', headers: headers, params: params get '/api/v2/search', headers: headers, params: params
expect(body_as_json[:accounts].pluck(:id)).to contain_exactly(ana.id.to_s) expect(response.parsed_body[:accounts].pluck(:id)).to contain_exactly(ana.id.to_s)
end end
end end
end end

View File

@ -22,7 +22,7 @@ RSpec.describe 'Suggestions API' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json).to match_array( expect(response.parsed_body).to match_array(
[bob, jeff].map do |account| [bob, jeff].map do |account|
hash_including({ hash_including({
source: 'staff', source: 'staff',

View File

@ -33,7 +33,7 @@ RSpec.describe 'Accounts in grouped notifications' do
# The group we are interested in is only favorites # The group we are interested in is only favorites
notifications = user.account.notifications.where(type: 'favourite').reorder(id: :desc) notifications = user.account.notifications.where(type: 'favourite').reorder(id: :desc)
expect(body_as_json).to match( expect(response.parsed_body).to match(
[ [
a_hash_including( a_hash_including(
id: notifications.first.from_account_id.to_s id: notifications.first.from_account_id.to_s
@ -58,7 +58,7 @@ RSpec.describe 'Accounts in grouped notifications' do
# The group we are interested in is only favorites # The group we are interested in is only favorites
notifications = user.account.notifications.where(type: 'favourite').reorder(id: :desc) notifications = user.account.notifications.where(type: 'favourite').reorder(id: :desc)
expect(body_as_json).to match( expect(response.parsed_body).to match(
[ [
a_hash_including( a_hash_including(
id: notifications.first.from_account_id.to_s id: notifications.first.from_account_id.to_s

View File

@ -31,7 +31,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:count]).to eq 4 expect(response.parsed_body[:count]).to eq 4
end end
end end
@ -42,7 +42,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:count]).to eq 5 expect(response.parsed_body[:count]).to eq 5
end end
end end
@ -56,7 +56,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:count]).to eq 2 expect(response.parsed_body[:count]).to eq 2
end end
end end
@ -67,7 +67,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:count]).to eq 3 expect(response.parsed_body[:count]).to eq 3
end end
end end
@ -78,7 +78,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:count]).to eq 2 expect(response.parsed_body[:count]).to eq 2
end end
end end
@ -91,7 +91,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:count]).to eq Api::V2Alpha::NotificationsController::DEFAULT_NOTIFICATIONS_COUNT_LIMIT expect(response.parsed_body[:count]).to eq Api::V2Alpha::NotificationsController::DEFAULT_NOTIFICATIONS_COUNT_LIMIT
end end
end end
end end
@ -125,7 +125,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:notification_groups]).to eq [] expect(response.parsed_body[:notification_groups]).to eq []
end end
end end
@ -145,7 +145,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:notification_groups]).to contain_exactly( expect(response.parsed_body[:notification_groups]).to contain_exactly(
a_hash_including( a_hash_including(
type: 'reblog', type: 'reblog',
sample_account_ids: [bob.account_id.to_s] sample_account_ids: [bob.account_id.to_s]
@ -177,7 +177,7 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json.size).to_not eq 0 expect(response.parsed_body.size).to_not eq 0
expect(body_json_types.uniq).to_not include 'mention' expect(body_json_types.uniq).to_not include 'mention'
end end
end end
@ -190,7 +190,7 @@ RSpec.describe 'Notifications' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_json_types.uniq).to eq ['mention'] expect(body_json_types.uniq).to eq ['mention']
expect(body_as_json.dig(:notification_groups, 0, :page_min_id)).to_not be_nil expect(response.parsed_body.dig(:notification_groups, 0, :page_min_id)).to_not be_nil
end end
end end
@ -201,7 +201,7 @@ RSpec.describe 'Notifications' do
it 'returns the requested number of notifications paginated', :aggregate_failures do it 'returns the requested number of notifications paginated', :aggregate_failures do
subject subject
expect(body_as_json[:notification_groups].size) expect(response.parsed_body[:notification_groups].size)
.to eq(params[:limit]) .to eq(params[:limit])
expect(response) expect(response)
@ -221,7 +221,7 @@ RSpec.describe 'Notifications' do
it 'returns the requested number of notifications paginated', :aggregate_failures do it 'returns the requested number of notifications paginated', :aggregate_failures do
subject subject
expect(body_as_json[:notification_groups].size) expect(response.parsed_body[:notification_groups].size)
.to eq(2) .to eq(2)
expect(response) expect(response)
@ -247,10 +247,10 @@ RSpec.describe 'Notifications' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:partial_accounts].size).to be > 0 expect(response.parsed_body[:partial_accounts].size).to be > 0
expect(body_as_json[:partial_accounts][0].keys.map(&:to_sym)).to contain_exactly(:acct, :avatar, :avatar_static, :bot, :id, :locked, :url) expect(response.parsed_body[:partial_accounts][0].keys.map(&:to_sym)).to contain_exactly(:acct, :avatar, :avatar_static, :bot, :id, :locked, :url)
expect(body_as_json[:partial_accounts].pluck(:id)).to_not include(recent_account.id.to_s) expect(response.parsed_body[:partial_accounts].pluck(:id)).to_not include(recent_account.id.to_s)
expect(body_as_json[:accounts].pluck(:id)).to include(recent_account.id.to_s) expect(response.parsed_body[:accounts].pluck(:id)).to include(recent_account.id.to_s)
end end
end end
@ -265,7 +265,7 @@ RSpec.describe 'Notifications' do
end end
def body_json_types def body_json_types
body_as_json[:notification_groups].pluck(:type) response.parsed_body[:notification_groups].pluck(:type)
end end
end end

View File

@ -18,7 +18,7 @@ RSpec.describe '/api/web/embed' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:html]).to be_present expect(response.parsed_body[:html]).to be_present
end end
end end
@ -71,7 +71,7 @@ RSpec.describe '/api/web/embed' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:html]).to be_present expect(response.parsed_body[:html]).to be_present
end end
context 'when the requesting user is blocked' do context 'when the requesting user is blocked' do
@ -133,7 +133,7 @@ RSpec.describe '/api/web/embed' do
subject subject
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_as_json[:html]).to be_present expect(response.parsed_body[:html]).to be_present
end end
end end

View File

@ -11,7 +11,7 @@ RSpec.describe 'Emojis' do
expect(response) expect(response)
.to have_http_status(200) .to have_http_status(200)
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
name: ':coolcat:', name: ':coolcat:',
type: 'Emoji' type: 'Emoji'

View File

@ -15,7 +15,7 @@ RSpec.describe 'Instance actor endpoint' do
.and have_cacheable_headers .and have_cacheable_headers
expect(response.content_type) expect(response.content_type)
.to start_with('application/activity+json') .to start_with('application/activity+json')
expect(body_as_json) expect(response.parsed_body)
.to include( .to include(
id: instance_actor_url, id: instance_actor_url,
type: 'Application', type: 'Application',

View File

@ -12,7 +12,7 @@ RSpec.describe 'invites' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response.media_type).to eq 'application/json' expect(response.media_type).to eq 'application/json'
expect(body_as_json[:invite_code]).to eq invite.code expect(response.parsed_body[:invite_code]).to eq invite.code
end end
end end

View File

@ -24,7 +24,7 @@ RSpec.describe 'Log Out' do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(response.media_type).to eq 'application/json' expect(response.media_type).to eq 'application/json'
expect(body_as_json[:redirect_to]).to eq '/auth/sign_in' expect(response.parsed_body[:redirect_to]).to eq '/auth/sign_in'
end end
end end
end end

Some files were not shown because too many files have changed in this diff Show More