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

@ -22,6 +22,8 @@ RSpec.describe 'Bookmarks' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.bookmarked?(status)).to be true
expect(response.parsed_body).to match(
@ -37,6 +39,8 @@ RSpec.describe 'Bookmarks' do
subject
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -51,6 +55,8 @@ RSpec.describe 'Bookmarks' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.bookmarked?(status)).to be true
end
end
@ -60,6 +66,8 @@ RSpec.describe 'Bookmarks' do
post '/api/v1/statuses/-1/bookmark', headers: headers
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -70,6 +78,8 @@ RSpec.describe 'Bookmarks' do
subject
expect(response).to have_http_status(401)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -93,6 +103,8 @@ RSpec.describe 'Bookmarks' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.bookmarked?(status)).to be false
expect(response.parsed_body).to match(
@ -113,6 +125,8 @@ RSpec.describe 'Bookmarks' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.bookmarked?(status)).to be false
expect(response.parsed_body).to match(
@ -126,6 +140,8 @@ RSpec.describe 'Bookmarks' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -137,6 +153,8 @@ RSpec.describe 'Bookmarks' do
subject
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end

View file

@ -33,6 +33,8 @@ RSpec.describe 'API V1 Statuses Favourited by Accounts' do
prev: api_v1_status_favourited_by_index_url(limit: 2, since_id: Favourite.last.id),
next: api_v1_status_favourited_by_index_url(limit: 2, max_id: Favourite.first.id)
)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.size)
.to eq(2)
@ -72,6 +74,8 @@ RSpec.describe 'API V1 Statuses Favourited by Accounts' do
subject
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -88,6 +92,8 @@ RSpec.describe 'API V1 Statuses Favourited by Accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
end
end

View file

@ -22,6 +22,8 @@ RSpec.describe 'Favourites', :inline_jobs do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.favourited?(status)).to be true
expect(response.parsed_body).to match(
@ -37,6 +39,8 @@ RSpec.describe 'Favourites', :inline_jobs do
subject
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -51,6 +55,8 @@ RSpec.describe 'Favourites', :inline_jobs do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.favourited?(status)).to be true
end
end
@ -62,6 +68,8 @@ RSpec.describe 'Favourites', :inline_jobs do
subject
expect(response).to have_http_status(401)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -84,6 +92,8 @@ RSpec.describe 'Favourites', :inline_jobs do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.favourited?(status)).to be false
@ -103,6 +113,8 @@ RSpec.describe 'Favourites', :inline_jobs do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.favourited?(status)).to be false
@ -117,6 +129,8 @@ RSpec.describe 'Favourites', :inline_jobs do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -127,6 +141,8 @@ RSpec.describe 'Favourites', :inline_jobs do
subject
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end

View file

@ -18,6 +18,8 @@ RSpec.describe 'API V1 Statuses Histories' do
it 'returns http success' do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.size).to_not be 0
end
end

View file

@ -18,6 +18,8 @@ RSpec.describe 'API V1 Statuses Mutes' do
it 'creates a conversation mute', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(ConversationMute.find_by(account: user.account, conversation_id: status.conversation_id)).to_not be_nil
end
end
@ -32,6 +34,8 @@ RSpec.describe 'API V1 Statuses Mutes' do
it 'destroys the conversation mute', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(ConversationMute.find_by(account: user.account, conversation_id: status.conversation_id)).to be_nil
end
end

View file

@ -22,6 +22,8 @@ RSpec.describe 'Pins' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.pinned?(status)).to be true
expect(response.parsed_body).to match(
@ -37,6 +39,8 @@ RSpec.describe 'Pins' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.pinned?(status)).to be true
end
end
@ -48,6 +52,8 @@ RSpec.describe 'Pins' do
subject
expect(response).to have_http_status(422)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -56,6 +62,8 @@ RSpec.describe 'Pins' do
post '/api/v1/statuses/-1/pin', headers: headers
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -66,6 +74,8 @@ RSpec.describe 'Pins' do
subject
expect(response).to have_http_status(401)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -86,6 +96,8 @@ RSpec.describe 'Pins' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.pinned?(status)).to be false
expect(response.parsed_body).to match(
@ -99,6 +111,8 @@ RSpec.describe 'Pins' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -107,6 +121,8 @@ RSpec.describe 'Pins' do
post '/api/v1/statuses/-1/unpin', headers: headers
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -117,6 +133,8 @@ RSpec.describe 'Pins' do
subject
expect(response).to have_http_status(401)
expect(response.content_type)
.to start_with('application/json')
end
end
end

View file

@ -32,6 +32,8 @@ RSpec.describe 'API V1 Statuses Reblogged by Accounts' do
prev: api_v1_status_reblogged_by_index_url(limit: 2, since_id: bob.statuses.first.id),
next: api_v1_status_reblogged_by_index_url(limit: 2, max_id: alice.statuses.first.id)
)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.size)
.to eq(2)
@ -71,6 +73,8 @@ RSpec.describe 'API V1 Statuses Reblogged by Accounts' do
subject
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -87,6 +91,8 @@ RSpec.describe 'API V1 Statuses Reblogged by Accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
end
end

View file

@ -19,6 +19,8 @@ RSpec.describe 'API V1 Statuses Reblogs' do
context 'with public status' do
it 'reblogs the status', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(status.reblogs.count).to eq 1
@ -40,6 +42,8 @@ RSpec.describe 'API V1 Statuses Reblogs' do
it 'returns http not found' do
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -55,6 +59,8 @@ RSpec.describe 'API V1 Statuses Reblogs' do
it 'destroys the reblog', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(status.reblogs.count).to eq 0
@ -80,6 +86,8 @@ RSpec.describe 'API V1 Statuses Reblogs' do
it 'destroys the reblog', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(status.reblogs.count).to eq 0
@ -103,6 +111,8 @@ RSpec.describe 'API V1 Statuses Reblogs' do
it 'returns http not found' do
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end

View file

@ -22,6 +22,8 @@ RSpec.describe 'Sources' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body).to match({
id: status.id.to_s,
text: status.text,
@ -37,6 +39,8 @@ RSpec.describe 'Sources' do
subject
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -51,6 +55,8 @@ RSpec.describe 'Sources' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body).to match({
id: status.id.to_s,
text: status.text,
@ -66,6 +72,8 @@ RSpec.describe 'Sources' do
subject
expect(response).to have_http_status(401)
expect(response.content_type)
.to start_with('application/json')
end
end
end

View file

@ -20,6 +20,8 @@ RSpec.describe 'API V1 Statuses Translations' do
it 'returns http unprocessable entity' do
expect(response).to have_http_status(422)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -38,6 +40,8 @@ RSpec.describe 'API V1 Statuses Translations' do
it 'returns http success' do
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
end
end