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

@ -17,6 +17,8 @@ RSpec.describe '/api/v1/accounts' do
get '/api/v1/accounts', headers: headers, params: { id: [account.id, other_account.id, 123_123] }
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body).to contain_exactly(
hash_including(id: account.id.to_s),
hash_including(id: other_account.id.to_s)
@ -32,6 +34,8 @@ RSpec.describe '/api/v1/accounts' do
get "/api/v1/accounts/#{account.id}"
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:id]).to eq(account.id.to_s)
end
end
@ -41,6 +45,8 @@ RSpec.describe '/api/v1/accounts' do
get '/api/v1/accounts/1'
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:error]).to eq('Record not found')
end
end
@ -57,6 +63,8 @@ RSpec.describe '/api/v1/accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:id]).to eq(account.id.to_s)
end
@ -80,6 +88,8 @@ RSpec.describe '/api/v1/accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:access_token]).to_not be_blank
user = User.find_by(email: 'hello@world.tld')
@ -93,6 +103,8 @@ RSpec.describe '/api/v1/accounts' do
subject
expect(response).to have_http_status(422)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -113,6 +125,8 @@ RSpec.describe '/api/v1/accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body)
.to include(
@ -133,6 +147,8 @@ RSpec.describe '/api/v1/accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body)
.to include(
@ -203,6 +219,8 @@ RSpec.describe '/api/v1/accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.following?(other_account)).to be false
end
@ -225,6 +243,8 @@ RSpec.describe '/api/v1/accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.followed_by?(other_account)).to be false
end
@ -247,6 +267,8 @@ RSpec.describe '/api/v1/accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.following?(other_account)).to be false
expect(user.account.blocking?(other_account)).to be true
end
@ -270,6 +292,8 @@ RSpec.describe '/api/v1/accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.blocking?(other_account)).to be false
end
@ -292,6 +316,8 @@ RSpec.describe '/api/v1/accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.following?(other_account)).to be true
expect(user.account.muting?(other_account)).to be true
expect(user.account.muting_notifications?(other_account)).to be true
@ -316,6 +342,8 @@ RSpec.describe '/api/v1/accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.following?(other_account)).to be true
expect(user.account.muting?(other_account)).to be true
expect(user.account.muting_notifications?(other_account)).to be false
@ -340,6 +368,8 @@ RSpec.describe '/api/v1/accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.following?(other_account)).to be true
expect(user.account.muting?(other_account)).to be true
expect(user.account.muting_notifications?(other_account)).to be true
@ -364,6 +394,8 @@ RSpec.describe '/api/v1/accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(user.account.muting?(other_account)).to be false
end