0
0
Fork 0

Use body_as_json directly instead of via local var assignment (#31696)

This commit is contained in:
Matt Jankowski 2024-09-03 04:03:08 -04:00 committed by GitHub
parent e5155c50fd
commit 24a0b20408
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 123 additions and 113 deletions

View file

@ -96,10 +96,11 @@ RSpec.describe 'Canonical Email Blocks' do
subject
expect(response).to have_http_status(200)
json = body_as_json
expect(json[:id]).to eq(canonical_email_block.id.to_s)
expect(json[:canonical_email_hash]).to eq(canonical_email_block.canonical_email_hash)
expect(body_as_json)
.to include(
id: eq(canonical_email_block.id.to_s),
canonical_email_hash: eq(canonical_email_block.canonical_email_hash)
)
end
end

View file

@ -133,10 +133,8 @@ RSpec.describe 'Domain Blocks' do
it 'creates a domain block with the expected domain name and severity', :aggregate_failures do
subject
body = body_as_json
expect(response).to have_http_status(200)
expect(body).to match a_hash_including(
expect(body_as_json).to match a_hash_including(
{
domain: 'foo.bar.com',
severity: 'silence',
@ -156,10 +154,8 @@ RSpec.describe 'Domain Blocks' do
it 'creates a domain block with the expected domain name and severity', :aggregate_failures do
subject
body = body_as_json
expect(response).to have_http_status(200)
expect(body).to match a_hash_including(
expect(body_as_json).to match a_hash_including(
{
domain: 'foo.bar.com',
severity: 'suspend',

View file

@ -88,10 +88,12 @@ RSpec.describe 'IP Blocks' do
subject
expect(response).to have_http_status(200)
json = body_as_json
expect(json[:ip]).to eq("#{ip_block.ip}/#{ip_block.ip.prefix}")
expect(json[:severity]).to eq(ip_block.severity.to_s)
expect(body_as_json)
.to include(
ip: eq("#{ip_block.ip}/#{ip_block.ip.prefix}"),
severity: eq(ip_block.severity.to_s)
)
end
context 'when ip block does not exist' do
@ -118,11 +120,12 @@ RSpec.describe 'IP Blocks' do
subject
expect(response).to have_http_status(200)
json = body_as_json
expect(json[:ip]).to eq("#{params[:ip]}/32")
expect(json[:severity]).to eq(params[:severity])
expect(json[:comment]).to eq(params[:comment])
expect(body_as_json)
.to include(
ip: eq("#{params[:ip]}/32"),
severity: eq(params[:severity]),
comment: eq(params[:comment])
)
end
context 'when the required ip param is not provided' do