Add response.content_type
checks for JSON to api/v1
request specs (#31981)
This commit is contained in:
parent
a7dbf6f5a5
commit
66326065b0
98 changed files with 930 additions and 14 deletions
|
@ -20,6 +20,8 @@ RSpec.describe 'credentials API' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to include({
|
||||
source: hash_including({
|
||||
discoverable: false,
|
||||
|
@ -36,6 +38,8 @@ RSpec.describe 'credentials API' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body).to include({
|
||||
locked: true,
|
||||
|
@ -75,6 +79,8 @@ RSpec.describe 'credentials API' do
|
|||
it 'returns http success' do
|
||||
subject
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -84,6 +90,8 @@ RSpec.describe 'credentials API' do
|
|||
it 'returns http unprocessable entity' do
|
||||
subject
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -92,6 +100,8 @@ RSpec.describe 'credentials API' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body).to include({
|
||||
source: hash_including({
|
||||
|
|
|
@ -14,6 +14,8 @@ RSpec.describe 'Accounts Familiar Followers API' do
|
|||
get '/api/v1/accounts/familiar_followers', params: { account_id: account.id, limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
|
||||
context 'when there are duplicate account IDs in the params' do
|
||||
|
|
|
@ -23,6 +23,8 @@ RSpec.describe 'account featured tags API' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to contain_exactly(a_hash_including({
|
||||
name: 'bar',
|
||||
url: "https://cb6e6126.ngrok.io/@#{account.username}/tagged/bar",
|
||||
|
@ -37,6 +39,8 @@ RSpec.describe 'account featured tags API' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body).to contain_exactly(a_hash_including({
|
||||
name: 'bar',
|
||||
url: "https://cb6e6126.ngrok.io/@#{account.pretty_acct}/tagged/bar",
|
||||
|
|
|
@ -21,6 +21,8 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
|
|||
get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to eq 2
|
||||
expect([response.parsed_body[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
|
||||
end
|
||||
|
@ -30,6 +32,8 @@ RSpec.describe 'API V1 Accounts FollowerAccounts' do
|
|||
get "/api/v1/accounts/#{account.id}/followers", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to eq 1
|
||||
expect(response.parsed_body[0][:id]).to eq alice.id.to_s
|
||||
end
|
||||
|
|
|
@ -21,6 +21,8 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
|
|||
get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to eq 2
|
||||
expect([response.parsed_body[0][:id], response.parsed_body[1][:id]]).to contain_exactly(alice.id.to_s, bob.id.to_s)
|
||||
end
|
||||
|
@ -30,6 +32,8 @@ RSpec.describe 'API V1 Accounts FollowingAccounts' do
|
|||
get "/api/v1/accounts/#{account.id}/following", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body.size).to eq 1
|
||||
expect(response.parsed_body[0][:id]).to eq alice.id.to_s
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ RSpec.describe 'Accounts Identity Proofs API' do
|
|||
get "/api/v1/accounts/#{account.id}/identity_proofs", params: { limit: 2 }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,8 @@ RSpec.describe 'Accounts Lists API' do
|
|||
get "/api/v1/accounts/#{account.id}/lists", headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,8 @@ RSpec.describe 'Accounts Lookup API' do
|
|||
get '/api/v1/accounts/lookup', params: { account_id: account.id, acct: account.acct }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,6 +22,8 @@ RSpec.describe 'Accounts Notes API' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(AccountNote.find_by(account_id: user.account.id, target_account_id: account.id).comment).to eq comment
|
||||
end
|
||||
end
|
||||
|
@ -33,6 +35,8 @@ RSpec.describe 'Accounts Notes API' do
|
|||
subject
|
||||
|
||||
expect(response).to have_http_status(422)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(AccountNote.where(account_id: user.account.id, target_account_id: account.id)).to_not exist
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,6 +21,8 @@ RSpec.describe 'Accounts Pins API' do
|
|||
subject
|
||||
end.to change { AccountPin.where(account: user.account, target_account: kevin.account).count }.by(1)
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -36,6 +38,8 @@ RSpec.describe 'Accounts Pins API' do
|
|||
subject
|
||||
end.to change { AccountPin.where(account: user.account, target_account: kevin.account).count }.by(-1)
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,6 +29,8 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
.and contain_exactly(
|
||||
|
@ -50,6 +52,8 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
.and have_attributes(
|
||||
|
@ -70,6 +74,8 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
.and have_attributes(
|
||||
|
@ -149,6 +155,8 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
|
@ -171,6 +179,8 @@ RSpec.describe 'GET /api/v1/accounts/relationships' do
|
|||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
|
||||
expect(response.parsed_body)
|
||||
.to be_an(Enumerable)
|
||||
|
|
|
@ -13,6 +13,8 @@ RSpec.describe 'Accounts Search API' do
|
|||
get '/api/v1/accounts/search', params: { q: 'query' }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,6 +19,8 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
prev: api_v1_account_statuses_url(limit: 1, min_id: status.id),
|
||||
next: api_v1_account_statuses_url(limit: 1, max_id: status.id)
|
||||
)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
|
||||
context 'with only media' do
|
||||
|
@ -26,6 +28,8 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
get "/api/v1/accounts/#{user.account.id}/statuses", params: { only_media: true }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,6 +45,8 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
it 'returns posts along with self replies', :aggregate_failures do
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
expect(response.parsed_body)
|
||||
.to have_attributes(size: 2)
|
||||
.and contain_exactly(
|
||||
|
@ -61,6 +67,8 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
expect(response)
|
||||
.to have_http_status(200)
|
||||
.and include_pagination_headers(prev: api_v1_account_statuses_url(pinned: true, min_id: Status.first.id))
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -79,6 +87,8 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
prev: api_v1_account_statuses_url(pinned: true, min_id: Status.first.id),
|
||||
next: api_v1_account_statuses_url(pinned: true, max_id: Status.first.id)
|
||||
)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -96,6 +106,8 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
get "/api/v1/accounts/#{account.id}/statuses", params: { pinned: true }, headers: headers
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
|
||||
context 'when user does not follow account' do
|
||||
|
@ -122,6 +134,8 @@ RSpec.describe 'API V1 Accounts Statuses' do
|
|||
a_hash_including(id: status.id.to_s),
|
||||
a_hash_including(id: private_status.id.to_s)
|
||||
)
|
||||
expect(response.content_type)
|
||||
.to start_with('application/json')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue