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

@ -24,6 +24,8 @@ RSpec.describe 'Canonical Email Blocks' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
context 'when there is no canonical email block' do
@ -96,6 +98,8 @@ RSpec.describe 'Canonical Email Blocks' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body)
.to include(
id: eq(canonical_email_block.id.to_s),
@ -109,6 +113,8 @@ RSpec.describe 'Canonical Email Blocks' do
get '/api/v1/admin/canonical_email_blocks/-1', headers: headers
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -131,6 +137,8 @@ RSpec.describe 'Canonical Email Blocks' do
subject
expect(response).to have_http_status(400)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -142,6 +150,8 @@ RSpec.describe 'Canonical Email Blocks' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.first[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
end
end
@ -151,6 +161,8 @@ RSpec.describe 'Canonical Email Blocks' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body).to be_empty
end
end
@ -173,6 +185,8 @@ RSpec.describe 'Canonical Email Blocks' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
end
@ -183,6 +197,8 @@ RSpec.describe 'Canonical Email Blocks' do
subject
expect(response).to have_http_status(422)
expect(response.content_type)
.to start_with('application/json')
end
end
@ -193,6 +209,8 @@ RSpec.describe 'Canonical Email Blocks' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:canonical_email_hash]).to eq(params[:canonical_email_hash])
end
end
@ -204,6 +222,8 @@ RSpec.describe 'Canonical Email Blocks' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
end
end
@ -217,6 +237,8 @@ RSpec.describe 'Canonical Email Blocks' do
subject
expect(response).to have_http_status(422)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -237,6 +259,8 @@ RSpec.describe 'Canonical Email Blocks' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(CanonicalEmailBlock.find_by(id: canonical_email_block.id)).to be_nil
end
@ -245,6 +269,8 @@ RSpec.describe 'Canonical Email Blocks' do
delete '/api/v1/admin/canonical_email_blocks/0', headers: headers
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end