Merge remote-tracking branch 'parent/main' into upstream-20240821
This commit is contained in:
commit
af0f8f01e1
136 changed files with 693 additions and 756 deletions
|
@ -120,4 +120,34 @@ RSpec.describe 'Requests' do
|
|||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /api/v1/notifications/requests/merged' do
|
||||
subject do
|
||||
get '/api/v1/notifications/requests/merged', headers: headers
|
||||
end
|
||||
|
||||
it_behaves_like 'forbidden for wrong scope', 'write write:notifications'
|
||||
|
||||
context 'when the user has no accepted request pending merge' do
|
||||
it 'returns http success and returns merged: true' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json).to eq({ merged: true })
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the user has an accepted request pending merge' do
|
||||
before do
|
||||
redis.set("notification_unfilter_jobs:#{user.account_id}", 1)
|
||||
end
|
||||
|
||||
it 'returns http success and returns merged: false' do
|
||||
subject
|
||||
|
||||
expect(response).to have_http_status(200)
|
||||
expect(body_as_json).to eq({ merged: false })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -185,7 +185,7 @@ RSpec.describe 'Notifications' do
|
|||
it 'returns the requested number of notifications paginated', :aggregate_failures do
|
||||
subject
|
||||
|
||||
notifications = user.account.notifications.browserable
|
||||
notifications = user.account.notifications.browserable.order(id: :asc)
|
||||
|
||||
expect(body_as_json.size)
|
||||
.to eq(params[:limit])
|
||||
|
|
|
@ -97,8 +97,7 @@ RSpec.describe 'Notifications' do
|
|||
before do
|
||||
first_status = PostStatusService.new.call(user.account, text: 'Test')
|
||||
ReblogService.new.call(bob.account, first_status)
|
||||
mentioning_status = PostStatusService.new.call(bob.account, text: 'Hello @alice')
|
||||
mentioning_status.mentions.first
|
||||
PostStatusService.new.call(bob.account, text: 'Hello @alice')
|
||||
FavouriteService.new.call(bob.account, first_status)
|
||||
FavouriteService.new.call(tom.account, first_status)
|
||||
FollowService.new.call(bob.account, user.account)
|
||||
|
@ -141,18 +140,37 @@ RSpec.describe 'Notifications' do
|
|||
|
||||
context 'with limit param' do
|
||||
let(:params) { { limit: 3 } }
|
||||
let(:notifications) { user.account.notifications.reorder(id: :desc) }
|
||||
|
||||
it 'returns the requested number of notifications paginated', :aggregate_failures do
|
||||
subject
|
||||
|
||||
notifications = user.account.notifications
|
||||
|
||||
expect(body_as_json[:notification_groups].size)
|
||||
.to eq(params[:limit])
|
||||
|
||||
expect(response)
|
||||
.to include_pagination_headers(
|
||||
prev: api_v2_alpha_notifications_url(limit: params[:limit], min_id: notifications.last.id),
|
||||
prev: api_v2_alpha_notifications_url(limit: params[:limit], min_id: notifications.first.id),
|
||||
# TODO: one downside of the current approach is that we return the first ID matching the group,
|
||||
# not the last that has been skipped, so pagination is very likely to give overlap
|
||||
next: api_v2_alpha_notifications_url(limit: params[:limit], max_id: notifications[3].id)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with since_id param' do
|
||||
let(:params) { { since_id: notifications[2].id } }
|
||||
let(:notifications) { user.account.notifications.reorder(id: :desc) }
|
||||
|
||||
it 'returns the requested number of notifications paginated', :aggregate_failures do
|
||||
subject
|
||||
|
||||
expect(body_as_json[:notification_groups].size)
|
||||
.to eq(2)
|
||||
|
||||
expect(response)
|
||||
.to include_pagination_headers(
|
||||
prev: api_v2_alpha_notifications_url(limit: params[:limit], min_id: notifications.first.id),
|
||||
# TODO: one downside of the current approach is that we return the first ID matching the group,
|
||||
# not the last that has been skipped, so pagination is very likely to give overlap
|
||||
next: api_v2_alpha_notifications_url(limit: params[:limit], max_id: notifications[1].id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue