diff --git a/spec/requests/api/v1/admin/canonical_email_blocks_spec.rb b/spec/requests/api/v1/admin/canonical_email_blocks_spec.rb index eaa011d516..25af0a26af 100644 --- a/spec/requests/api/v1/admin/canonical_email_blocks_spec.rb +++ b/spec/requests/api/v1/admin/canonical_email_blocks_spec.rb @@ -20,19 +20,16 @@ RSpec.describe 'Canonical Email Blocks' do it_behaves_like 'forbidden for wrong role', '' it_behaves_like 'forbidden for wrong role', 'Moderator' - it 'returns http success' 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 it 'returns an empty list' do subject - expect(response.parsed_body).to be_empty + 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 @@ -43,7 +40,12 @@ RSpec.describe 'Canonical Email Blocks' do it 'returns the correct canonical email hashes' do subject - expect(response.parsed_body.pluck(:canonical_email_hash)).to match_array(expected_email_hashes) + expect(response) + .to have_http_status(200) + expect(response.content_type) + .to start_with('application/json') + expect(response.parsed_body.pluck(:canonical_email_hash)) + .to match_array(expected_email_hashes) end context 'with limit param' do diff --git a/spec/requests/api/v1/admin/domain_allows_spec.rb b/spec/requests/api/v1/admin/domain_allows_spec.rb index eb5128e420..fba1eb15d3 100644 --- a/spec/requests/api/v1/admin/domain_allows_spec.rb +++ b/spec/requests/api/v1/admin/domain_allows_spec.rb @@ -20,18 +20,14 @@ RSpec.describe 'Domain Allows' do it_behaves_like 'forbidden for wrong role', '' it_behaves_like 'forbidden for wrong role', 'Moderator' - it 'returns http success' do - subject - - expect(response).to have_http_status(200) - expect(response.content_type) - .to start_with('application/json') - end - context 'when there is no allowed domains' do it 'returns an empty body' 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 @@ -51,7 +47,12 @@ RSpec.describe 'Domain Allows' do it 'returns the correct allowed domains' do subject - expect(response.parsed_body).to match_array(expected_response) + expect(response) + .to have_http_status(200) + expect(response.content_type) + .to start_with('application/json') + expect(response.parsed_body) + .to match_array(expected_response) end context 'with limit param' do diff --git a/spec/requests/api/v1/admin/domain_blocks_spec.rb b/spec/requests/api/v1/admin/domain_blocks_spec.rb index 1a506bd9be..029de72fd7 100644 --- a/spec/requests/api/v1/admin/domain_blocks_spec.rb +++ b/spec/requests/api/v1/admin/domain_blocks_spec.rb @@ -20,19 +20,16 @@ RSpec.describe 'Domain Blocks' do it_behaves_like 'forbidden for wrong role', '' it_behaves_like 'forbidden for wrong role', 'Moderator' - it 'returns http success' do - subject - - expect(response).to have_http_status(200) - expect(response.content_type) - .to start_with('application/json') - end - context 'when there are no domain blocks' do it 'returns an empty list' do subject - expect(response.parsed_body).to be_empty + 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 @@ -66,7 +63,12 @@ RSpec.describe 'Domain Blocks' do it 'returns the expected domain blocks' do subject - expect(response.parsed_body).to match_array(expected_responde) + expect(response) + .to have_http_status(200) + expect(response.content_type) + .to start_with('application/json') + expect(response.parsed_body) + .to match_array(expected_responde) end context 'with limit param' do diff --git a/spec/requests/api/v1/admin/email_domain_blocks_spec.rb b/spec/requests/api/v1/admin/email_domain_blocks_spec.rb index 3f51a3ea2d..2788a45a4a 100644 --- a/spec/requests/api/v1/admin/email_domain_blocks_spec.rb +++ b/spec/requests/api/v1/admin/email_domain_blocks_spec.rb @@ -21,19 +21,16 @@ RSpec.describe 'Email Domain Blocks' do it_behaves_like 'forbidden for wrong role', '' it_behaves_like 'forbidden for wrong role', 'Moderator' - it 'returns http success' do - subject - - expect(response).to have_http_status(200) - expect(response.content_type) - .to start_with('application/json') - end - context 'when there is no email domain block' do it 'returns an empty list' do subject - expect(response.parsed_body).to be_empty + 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 @@ -44,7 +41,12 @@ RSpec.describe 'Email Domain Blocks' do it 'return the correct blocked email domains' do subject - expect(response.parsed_body.pluck(:domain)).to match_array(blocked_email_domains) + expect(response) + .to have_http_status(200) + expect(response.content_type) + .to start_with('application/json') + expect(response.parsed_body.pluck(:domain)) + .to match_array(blocked_email_domains) end context 'with limit param' do diff --git a/spec/requests/api/v1/admin/ip_blocks_spec.rb b/spec/requests/api/v1/admin/ip_blocks_spec.rb index c096aa3328..aa3db33915 100644 --- a/spec/requests/api/v1/admin/ip_blocks_spec.rb +++ b/spec/requests/api/v1/admin/ip_blocks_spec.rb @@ -20,19 +20,16 @@ RSpec.describe 'IP Blocks' do it_behaves_like 'forbidden for wrong role', '' it_behaves_like 'forbidden for wrong role', 'Moderator' - it 'returns http success' do - subject - - expect(response).to have_http_status(200) - expect(response.content_type) - .to start_with('application/json') - end - context 'when there is no ip block' do it 'returns an empty body' do subject - expect(response.parsed_body).to be_empty + 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 @@ -60,7 +57,12 @@ RSpec.describe 'IP Blocks' do it 'returns the correct blocked ips' do subject - expect(response.parsed_body).to match_array(expected_response) + expect(response) + .to have_http_status(200) + expect(response.content_type) + .to start_with('application/json') + expect(response.parsed_body) + .to match_array(expected_response) end context 'with limit param' do diff --git a/spec/requests/api/v1/admin/reports_spec.rb b/spec/requests/api/v1/admin/reports_spec.rb index a0e7b0a369..987f0eda7f 100644 --- a/spec/requests/api/v1/admin/reports_spec.rb +++ b/spec/requests/api/v1/admin/reports_spec.rb @@ -19,19 +19,16 @@ RSpec.describe 'Reports' do it_behaves_like 'forbidden for wrong scope', 'write:statuses' it_behaves_like 'forbidden for wrong role', '' - it 'returns http success' do - subject - - expect(response).to have_http_status(200) - expect(response.content_type) - .to start_with('application/json') - end - context 'when there are no reports' do it 'returns an empty list' do subject - expect(response.parsed_body).to be_empty + 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 @@ -66,7 +63,12 @@ RSpec.describe 'Reports' do it 'returns all unresolved reports' do subject - expect(response.parsed_body).to match_array(expected_response) + expect(response) + .to have_http_status(200) + expect(response.content_type) + .to start_with('application/json') + expect(response.parsed_body) + .to match_array(expected_response) end context 'with resolved param' do diff --git a/spec/requests/api/v1/admin/tags_spec.rb b/spec/requests/api/v1/admin/tags_spec.rb index 696a11da67..3a57432af7 100644 --- a/spec/requests/api/v1/admin/tags_spec.rb +++ b/spec/requests/api/v1/admin/tags_spec.rb @@ -20,19 +20,16 @@ RSpec.describe 'Tags' do it_behaves_like 'forbidden for wrong scope', 'write:statuses' it_behaves_like 'forbidden for wrong role', '' - it 'returns http success' do - subject - - expect(response).to have_http_status(200) - expect(response.content_type) - .to start_with('application/json') - end - context 'when there are no tags' do it 'returns an empty list' do subject - expect(response.parsed_body).to be_empty + 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 @@ -48,6 +45,11 @@ RSpec.describe 'Tags' do it 'returns the expected tags' do subject + + expect(response) + .to have_http_status(200) + expect(response.content_type) + .to start_with('application/json') tags.each do |tag| expect(response.parsed_body.find { |item| item[:id] == tag.id.to_s && item[:name] == tag.name }).to_not be_nil end