Add response.content_type checks for JSON to api/v1 request specs (#31981)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user