Skip to content

Commit 9df55f2

Browse files
committed
person/notifications: respect show_maximum param
- Implement for /my/notifications. - Add specs for default behavior, limited results and capping at Notification.max_per_page. - Defensive filter handling and improved comments. Fixes #18910.
1 parent 5ae2ffe commit 9df55f2

File tree

10 files changed

+40
-7
lines changed

10 files changed

+40
-7
lines changed

.circleci/conditional_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ aliases:
7171
bundle config build.nokogiri --use-system-libraries
7272
bundle config build.sassc --disable-march-tune-native
7373
bundle config build.nio4r --with-cflags='-Wno-return-type'
74+
bundle config build.xmlhash --with-cflags='-Wno-error=shorten-64-to-32'
7475
bundle config set --local path 'vendor/bundle'
7576
bundle install --jobs=4 --retry=3 --local
7677

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.4.2
1+
3.2.2

.vscode/c_cpp_properties.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Mac",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/Headers"
8+
],
9+
"defines": [],
10+
"compilerPath": "/usr/bin/clang",
11+
"cStandard": "c17",
12+
"cppStandard": "c++14",
13+
"intelliSenseMode": "macos-clang-arm64"
14+
}
15+
],
16+
"version": 4
17+
}

src/api/.bundle/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
BUNDLE_BUILD__XMLHASH: "--with-cflags='-Wno-error=shorten-64-to-32'"

src/api/Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ GEM
414414
zeitwerk (~> 2.6)
415415
rainbow (3.1.1)
416416
rake (13.2.1)
417-
rantly (3.0.0)
417+
rantly (2.0.0)
418418
rbtree (0.4.6)
419419
rbtree3 (0.7.1)
420420
rdoc (6.16.0)

src/api/spec/controllers/person/notifications_controller_spec.rb

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,33 @@
2424

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

2929
before do
3030
login user
31-
get :index, format: :xml
32-
3331
notifications.each do |notification|
3432
notification.projects << user.home_project
3533
notification.save
3634
end
3735
end
3836

39-
it { expect(response).to have_http_status(:success) }
40-
it { expect(response.body).to include('<notifications count="2">') }
37+
it 'returns all notifications by default' do
38+
get :index, format: :xml
39+
expect(response).to have_http_status(:success)
40+
expect(response.body).to include('<notifications count="5">')
41+
end
42+
43+
it 'returns limited notifications when show_maximum is set' do
44+
get :index, params: { format: :xml, show_maximum: 3 }
45+
expect(response).to have_http_status(:success)
46+
expect(response.body).to include('<notifications count="3">')
47+
end
48+
49+
it 'caps show_maximum at Notification.max_per_page' do
50+
get :index, params: { format: :xml, show_maximum: 999 }
51+
expect(response).to have_http_status(:success)
52+
expect(response.body).to include("<notifications count=\"#{Notification.max_per_page}\">")
53+
end
4154

4255
context 'filter by kind' do
4356
let!(:notifications) { create_list(:notification_for_request, 2, :web_notification, :request_state_change, subscriber: user, delivered: true) }
590 KB
Binary file not shown.
6.25 MB
Binary file not shown.
18.5 KB
Binary file not shown.
-18.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)