gearheads
/
mastodon
Archived
2
0
Fork 0

Combine assertions in api/v1/notifications spec (#25486)

gh/dev
Matt Jankowski 2023-06-19 03:05:42 -04:00 committed by GitHub
parent 155ec185b2
commit e835198b26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 31 deletions

View File

@ -67,24 +67,13 @@ RSpec.describe Api::V1::NotificationsController do
get :index get :index
end end
it 'returns http success' do it 'returns expected notification types', :aggregate_failures do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
end
it 'includes reblog' do expect(body_json_types).to include 'reblog'
expect(body_as_json.pluck(:type)).to include 'reblog' expect(body_json_types).to include 'mention'
end expect(body_json_types).to include 'favourite'
expect(body_json_types).to include 'follow'
it 'includes mention' do
expect(body_as_json.pluck(:type)).to include 'mention'
end
it 'includes favourite' do
expect(body_as_json.pluck(:type)).to include 'favourite'
end
it 'includes follow' do
expect(body_as_json.pluck(:type)).to include 'follow'
end end
end end
@ -93,12 +82,14 @@ RSpec.describe Api::V1::NotificationsController do
get :index, params: { account_id: third.account.id } get :index, params: { account_id: third.account.id }
end end
it 'returns http success' do it 'returns only notifications from specified user', :aggregate_failures do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_json_account_ids.uniq).to eq [third.account.id.to_s]
end end
it 'returns only notifications from specified user' do def body_json_account_ids
expect(body_as_json.map { |x| x[:account][:id] }.uniq).to eq [third.account.id.to_s] body_as_json.map { |x| x[:account][:id] }
end end
end end
@ -107,27 +98,23 @@ RSpec.describe Api::V1::NotificationsController do
get :index, params: { account_id: 'foo' } get :index, params: { account_id: 'foo' }
end end
it 'returns http success' do it 'returns nothing', :aggregate_failures do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
end
it 'returns nothing' do
expect(body_as_json.size).to eq 0 expect(body_as_json.size).to eq 0
end end
end end
describe 'with excluded_types param' do describe 'with exclude_types param' do
before do before do
get :index, params: { exclude_types: %w(mention) } get :index, params: { exclude_types: %w(mention) }
end end
it 'returns http success' do it 'returns everything but excluded type', :aggregate_failures do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
end
it 'returns everything but excluded type' do
expect(body_as_json.size).to_not eq 0 expect(body_as_json.size).to_not eq 0
expect(body_as_json.pluck(:type).uniq).to_not include 'mention' expect(body_json_types.uniq).to_not include 'mention'
end end
end end
@ -136,13 +123,15 @@ RSpec.describe Api::V1::NotificationsController do
get :index, params: { types: %w(mention) } get :index, params: { types: %w(mention) }
end end
it 'returns http success' do it 'returns only requested type', :aggregate_failures do
expect(response).to have_http_status(200) expect(response).to have_http_status(200)
expect(body_json_types.uniq).to eq ['mention']
end
end end
it 'returns only requested type' do def body_json_types
expect(body_as_json.pluck(:type).uniq).to eq ['mention'] body_as_json.pluck(:type)
end
end end
end end
end end