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

@ -31,6 +31,8 @@ RSpec.describe 'Notifications' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:count]).to eq 5
end
end
@ -45,6 +47,8 @@ RSpec.describe 'Notifications' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:count]).to eq 2
end
end
@ -56,6 +60,8 @@ RSpec.describe 'Notifications' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:count]).to eq 4
end
end
@ -67,6 +73,8 @@ RSpec.describe 'Notifications' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:count]).to eq 2
end
end
@ -80,6 +88,8 @@ RSpec.describe 'Notifications' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body[:count]).to eq Api::V1::NotificationsController::DEFAULT_NOTIFICATIONS_COUNT_LIMIT
end
end
@ -111,6 +121,8 @@ RSpec.describe 'Notifications' 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 5
expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow')
expect(response.parsed_body.any? { |x| x[:filtered] }).to be false
@ -124,6 +136,8 @@ RSpec.describe 'Notifications' 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 6
expect(body_json_types).to include('reblog', 'mention', 'favourite', 'follow')
expect(response.parsed_body.any? { |x| x[:filtered] }).to be true
@ -137,6 +151,8 @@ RSpec.describe 'Notifications' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(body_json_account_ids.uniq).to eq [tom.account.id.to_s]
end
@ -152,6 +168,8 @@ RSpec.describe 'Notifications' 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 0
end
end
@ -163,6 +181,8 @@ RSpec.describe 'Notifications' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(response.parsed_body.size).to_not eq 0
expect(body_json_types.uniq).to_not include 'mention'
end
@ -175,6 +195,8 @@ RSpec.describe 'Notifications' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect(body_json_types.uniq).to eq ['mention']
end
end
@ -216,6 +238,8 @@ RSpec.describe 'Notifications' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
context 'when notification belongs to someone else' do
@ -225,6 +249,8 @@ RSpec.describe 'Notifications' do
subject
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -242,6 +268,8 @@ RSpec.describe 'Notifications' do
subject
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
expect { notification.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
@ -252,6 +280,8 @@ RSpec.describe 'Notifications' do
subject
expect(response).to have_http_status(404)
expect(response.content_type)
.to start_with('application/json')
end
end
end
@ -272,6 +302,8 @@ RSpec.describe 'Notifications' do
expect(user.account.reload.notifications).to be_empty
expect(response).to have_http_status(200)
expect(response.content_type)
.to start_with('application/json')
end
end
end