diff --git a/.circleci/conditional_config.yml b/.circleci/conditional_config.yml index 333428aaf27..3bdfc6c7bb7 100644 --- a/.circleci/conditional_config.yml +++ b/.circleci/conditional_config.yml @@ -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 diff --git a/.ruby-version b/.ruby-version index 4d9d11cf505..be94e6f53db 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.4.2 +3.2.2 diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000000..08d2123a3bd --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -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 +} \ No newline at end of file diff --git a/src/api/.bundle/config b/src/api/.bundle/config new file mode 100644 index 00000000000..eb06b6757bb --- /dev/null +++ b/src/api/.bundle/config @@ -0,0 +1,2 @@ +--- +BUNDLE_BUILD__XMLHASH: "--with-cflags='-Wno-error=shorten-64-to-32'" diff --git a/src/api/Gemfile.lock b/src/api/Gemfile.lock index 4a1c32e744a..47bd9c4788f 100644 --- a/src/api/Gemfile.lock +++ b/src/api/Gemfile.lock @@ -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) diff --git a/src/api/app/controllers/person/notifications_controller.rb b/src/api/app/controllers/person/notifications_controller.rb index 1ded5b5421a..0286b9d4e48 100644 --- a/src/api/app/controllers/person/notifications_controller.rb +++ b/src/api/app/controllers/person/notifications_controller.rb @@ -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 @@ -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 diff --git a/src/api/spec/controllers/person/notifications_controller_spec.rb b/src/api/spec/controllers/person/notifications_controller_spec.rb index edd754f4459..86dc3694e99 100644 --- a/src/api/spec/controllers/person/notifications_controller_spec.rb +++ b/src/api/spec/controllers/person/notifications_controller_spec.rb @@ -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('') } + it 'returns all notifications by default' do + get :index, format: :xml + expect(response).to have_http_status(:success) + expect(response.body).to include('') + 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('') + 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("") + end context 'filter by kind' do let!(:notifications) { create_list(:notification_for_request, 2, :web_notification, :request_state_change, subscriber: user, delivered: true) } diff --git a/src/api/vendor/cache/ffi-1.17.2-arm64-darwin.gem b/src/api/vendor/cache/ffi-1.17.2-arm64-darwin.gem new file mode 100644 index 00000000000..2219753b41f Binary files /dev/null and b/src/api/vendor/cache/ffi-1.17.2-arm64-darwin.gem differ diff --git a/src/api/vendor/cache/nokogiri-1.18.10-arm64-darwin.gem b/src/api/vendor/cache/nokogiri-1.18.10-arm64-darwin.gem new file mode 100644 index 00000000000..029fa10d17d Binary files /dev/null and b/src/api/vendor/cache/nokogiri-1.18.10-arm64-darwin.gem differ diff --git a/src/api/vendor/cache/rantly-2.0.0.gem b/src/api/vendor/cache/rantly-2.0.0.gem new file mode 100644 index 00000000000..e93b8695bd8 Binary files /dev/null and b/src/api/vendor/cache/rantly-2.0.0.gem differ diff --git a/src/api/vendor/cache/rantly-3.0.0.gem b/src/api/vendor/cache/rantly-3.0.0.gem deleted file mode 100644 index d375174d849..00000000000 Binary files a/src/api/vendor/cache/rantly-3.0.0.gem and /dev/null differ