2
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
98 changed files with 930 additions and 14 deletions

View File

@@ -19,6 +19,8 @@ RSpec.describe 'Accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.pluck(:id)).to match_array(expected_results.map { |a| a.id.to_s })
end
end
@@ -93,6 +95,8 @@ RSpec.describe 'Accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.size).to eq(params[:limit])
end
end
@@ -112,6 +116,8 @@ RSpec.describe 'Accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body).to match(
a_hash_including(id: account.id.to_s, username: account.username, email: account.user.email)
)
@@ -122,6 +128,8 @@ RSpec.describe 'Accounts' do
get '/api/v1/admin/accounts/-1', headers: headers
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@@ -145,6 +153,8 @@ RSpec.describe 'Accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(account.reload.user_approved?).to be(true)
end
@@ -166,6 +176,8 @@ RSpec.describe 'Accounts' do
subject
expect(response).to have_http_status(403)
expect(response.content_type)
.to start_with('application/json')
end
end
@@ -174,6 +186,8 @@ RSpec.describe 'Accounts' do
post '/api/v1/admin/accounts/-1/approve', headers: headers
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@@ -197,6 +211,8 @@ RSpec.describe 'Accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(User.where(id: account.user.id)).to_not exist
expect(latest_admin_action_log)
@@ -214,6 +230,8 @@ RSpec.describe 'Accounts' do
subject
expect(response).to have_http_status(403)
expect(response.content_type)
.to start_with('application/json')
end
end
@@ -222,6 +240,8 @@ RSpec.describe 'Accounts' do
post '/api/v1/admin/accounts/-1/reject', headers: headers
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@@ -244,6 +264,8 @@ RSpec.describe 'Accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(account.reload.user_disabled?).to be false
end
@@ -252,6 +274,8 @@ RSpec.describe 'Accounts' do
post '/api/v1/admin/accounts/-1/enable', headers: headers
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@@ -275,6 +299,8 @@ RSpec.describe 'Accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(account.reload.suspended?).to be false
end
end
@@ -284,6 +310,8 @@ RSpec.describe 'Accounts' do
subject
expect(response).to have_http_status(403)
expect(response.content_type)
.to start_with('application/json')
end
end
@@ -292,6 +320,8 @@ RSpec.describe 'Accounts' do
post '/api/v1/admin/accounts/-1/unsuspend', headers: headers
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@@ -314,6 +344,8 @@ RSpec.describe 'Accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(account.reload.sensitized?).to be false
end
@@ -322,6 +354,8 @@ RSpec.describe 'Accounts' do
post '/api/v1/admin/accounts/-1/unsensitive', headers: headers
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@@ -344,6 +378,8 @@ RSpec.describe 'Accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(account.reload.silenced?).to be false
end
@@ -352,6 +388,8 @@ RSpec.describe 'Accounts' do
post '/api/v1/admin/accounts/-1/unsilence', headers: headers
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@@ -376,6 +414,8 @@ RSpec.describe 'Accounts' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(Admin::AccountDeletionWorker).to have_received(:perform_async).with(account.id).once
end
end
@@ -393,6 +433,8 @@ RSpec.describe 'Accounts' do
delete '/api/v1/admin/accounts/-1', headers: headers
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end