0
0
Fork 0

Add response.content_type checks for JSON to api/v1 request specs (#31981)

This commit is contained in:
Matt Jankowski 2024-09-20 09:13:04 -04:00 committed by GitHub
parent a7dbf6f5a5
commit 66326065b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
98 changed files with 930 additions and 14 deletions

View file

@ -35,6 +35,8 @@ RSpec.describe 'Home', :inline_jobs do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.pluck(:id)).to match_array(home_statuses.map { |status| status.id.to_s })
end
@ -52,6 +54,8 @@ RSpec.describe 'Home', :inline_jobs do
prev: api_v1_timelines_home_url(limit: params[:limit], min_id: ana.statuses.first.id),
next: api_v1_timelines_home_url(limit: params[:limit], max_id: ana.statuses.first.id)
)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -67,6 +71,8 @@ RSpec.describe 'Home', :inline_jobs do
subject
expect(response).to have_http_status(206)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -77,6 +83,8 @@ RSpec.describe 'Home', :inline_jobs do
subject
expect(response).to have_http_status(401)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -89,6 +97,8 @@ RSpec.describe 'Home', :inline_jobs do
expect(response)
.to have_http_status(422)
.and not_have_http_link_header
expect(response.content_type)
.to start_with('application/json')
end
end
end

View file

@ -13,6 +13,8 @@ RSpec.describe 'Link' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.pluck(:id)).to match_array(expected_statuses.map { |status| status.id.to_s })
end
end
@ -50,6 +52,8 @@ RSpec.describe 'Link' do
subject
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -62,6 +66,8 @@ RSpec.describe 'Link' do
subject
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -74,6 +80,8 @@ RSpec.describe 'Link' do
subject
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -91,6 +99,8 @@ RSpec.describe 'Link' do
subject
expect(response).to have_http_status(422)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -101,6 +111,8 @@ RSpec.describe 'Link' do
subject
expect(response).to have_http_status(422)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -127,6 +139,8 @@ RSpec.describe 'Link' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.size).to eq(params[:limit])
expect(response)

View file

@ -23,6 +23,8 @@ RSpec.describe 'API V1 Timelines List' do
get "/api/v1/timelines/list/#{list.id}", headers: headers
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -36,6 +38,8 @@ RSpec.describe 'API V1 Timelines List' do
get "/api/v1/timelines/list/#{list.id}", headers: headers
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end

View file

@ -13,6 +13,8 @@ RSpec.describe 'Public' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.pluck(:id)).to match_array(expected_statuses.map { |status| status.id.to_s })
end
end
@ -77,15 +79,13 @@ RSpec.describe 'Public' do
context 'with limit param' do
let(:params) { { limit: 1 } }
it 'returns only the requested number of statuses', :aggregate_failures do
it 'returns only the requested number of statuses and sets pagination headers', :aggregate_failures do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.size).to eq(params[:limit])
end
it 'sets the correct pagination headers', :aggregate_failures do
subject
expect(response)
.to include_pagination_headers(
@ -110,6 +110,8 @@ RSpec.describe 'Public' do
subject
expect(response).to have_http_status(422)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -120,6 +122,8 @@ RSpec.describe 'Public' do
subject
expect(response).to have_http_status(422)
expect(response.content_type)
.to start_with('application/json')
end
end

View file

@ -19,6 +19,8 @@ RSpec.describe 'Tag' do
expect(response)
.to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.pluck(:id))
.to match_array(expected_statuses.map { |status| status.id.to_s })
.and not_include(private_status.id)
@ -81,6 +83,8 @@ RSpec.describe 'Tag' do
prev: api_v1_timelines_tag_url(limit: params[:limit], min_id: love_status.id),
next: api_v1_timelines_tag_url(limit: params[:limit], max_id: love_status.id)
)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -107,6 +111,8 @@ RSpec.describe 'Tag' do
subject
expect(response).to have_http_status(422)
expect(response.content_type)
.to start_with('application/json')
end
end