Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .circleci/conditional_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ aliases:
bundle config build.nokogiri --use-system-libraries
bundle config build.sassc --disable-march-tune-native
bundle config build.nio4r --with-cflags='-Wno-return-type'
bundle config build.xmlhash --with-cflags='-Wno-error=shorten-64-to-32'
bundle config set --local path 'vendor/bundle'
bundle install --jobs=4 --retry=3 --local

Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.2
3.2.2
17 changes: 17 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/Headers"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "macos-clang-arm64"
}
],
"version": 4
}
2 changes: 2 additions & 0 deletions src/api/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_BUILD__XMLHASH: "--with-cflags='-Wno-error=shorten-64-to-32'"
2 changes: 1 addition & 1 deletion src/api/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rantly (3.0.0)
rantly (2.0.0)
rbtree (0.4.6)
rbtree3 (0.7.1)
rdoc (6.16.0)
Expand Down
13 changes: 10 additions & 3 deletions src/api/app/controllers/person/notifications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ class NotificationsController < ApplicationController

# GET /my/notifications
def index
# If you pass show_maximum as a query parameter, you'll get up to that many notifications (capped at max_per_page).
# This matches what clients expect and fixes the old behavior where it always used total. See issue #18910.
@notifications_count = @notifications.count
@paged_notifications = @notifications.order(created_at: :desc).page(params[:page])

params[:page] = @paged_notifications.total_pages if @paged_notifications.out_of_range?
params[:show_maximum] ? show_maximum(@notifications) : @paged_notifications
if params[:show_maximum]
show_maximum(@notifications)
else
@paged_notifications
end
end

def update
Expand Down Expand Up @@ -55,8 +61,9 @@ def filter_notifications_by_state(notifications, filter_state)
end

def show_maximum(notifications)
total = notifications.size
notifications.page(params[:page]).per([total, Notification.max_per_page].min)
max = params[:show_maximum].to_i
max = Notification.max_per_page if max <= 0 || max > Notification.max_per_page
notifications.order(created_at: :desc).limit(max)
end

def set_filter_kind
Expand Down
23 changes: 18 additions & 5 deletions src/api/spec/controllers/person/notifications_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,33 @@

describe 'index' do
context 'called by authorized user' do
let!(:notifications) { create_list(:notification_for_request, 2, :web_notification, :request_state_change, subscriber: user) }
let!(:notifications) { create_list(:notification_for_request, 5, :web_notification, :request_state_change, subscriber: user) }

before do
login user
get :index, format: :xml

notifications.each do |notification|
notification.projects << user.home_project
notification.save
end
end

it { expect(response).to have_http_status(:success) }
it { expect(response.body).to include('<notifications count="2">') }
it 'returns all notifications by default' do
get :index, format: :xml
expect(response).to have_http_status(:success)
expect(response.body).to include('<notifications count="5">')
end

it 'returns limited notifications when show_maximum is set' do
get :index, params: { format: :xml, show_maximum: 3 }
expect(response).to have_http_status(:success)
expect(response.body).to include('<notifications count="3">')
end

it 'caps show_maximum at Notification.max_per_page' do
get :index, params: { format: :xml, show_maximum: 999 }
expect(response).to have_http_status(:success)
expect(response.body).to include("<notifications count=\"#{Notification.max_per_page}\">")
end

context 'filter by kind' do
let!(:notifications) { create_list(:notification_for_request, 2, :web_notification, :request_state_change, subscriber: user, delivered: true) }
Expand Down
Binary file added src/api/vendor/cache/ffi-1.17.2-arm64-darwin.gem
Binary file not shown.
Binary file not shown.
Binary file added src/api/vendor/cache/rantly-2.0.0.gem
Binary file not shown.
Binary file removed src/api/vendor/cache/rantly-3.0.0.gem
Binary file not shown.