From a6eb331710e128f1585b08d64467fdc034f08f13 Mon Sep 17 00:00:00 2001 From: Alp Keser Date: Tue, 3 Feb 2026 11:51:19 +0300 Subject: [PATCH] Fix query parameter name --- app/controllers/notifications/trays_controller.rb | 8 ++++---- test/controllers/notifications/trays_controller_test.rb | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/notifications/trays_controller.rb b/app/controllers/notifications/trays_controller.rb index fac108370..46dc445cf 100644 --- a/app/controllers/notifications/trays_controller.rb +++ b/app/controllers/notifications/trays_controller.rb @@ -3,13 +3,13 @@ class Notifications::TraysController < ApplicationController def show @notifications = unread_notifications - if include_unread? + if include_read? @notifications += read_notifications end # Invalidate on the whole set instead of the unread set since the max updated at in the unread set # can stay the same when reading old notifications. - fresh_when etag: [ Current.user.notifications, include_unread? ] + fresh_when etag: [ Current.user.notifications, include_read? ] end private @@ -21,7 +21,7 @@ class Notifications::TraysController < ApplicationController Current.user.notifications.read.preloaded.ordered.limit(MAX_ENTRIES_LIMIT) end - def include_unread? - ActiveModel::Type::Boolean.new.cast(params[:include_unread]) + def include_read? + ActiveModel::Type::Boolean.new.cast(params[:include_read]) end end diff --git a/test/controllers/notifications/trays_controller_test.rb b/test/controllers/notifications/trays_controller_test.rb index 89dc42c6f..b6efa200b 100644 --- a/test/controllers/notifications/trays_controller_test.rb +++ b/test/controllers/notifications/trays_controller_test.rb @@ -21,12 +21,12 @@ class Notifications::TraysControllerTest < ActionDispatch::IntegrationTest assert_equal expected_ids, @response.parsed_body.map { |s| s["id"] } end - test "show as JSON with include_unread includes read notifications" do + test "show as JSON with include_read includes read notifications" do notifications = users(:kevin).notifications expected_ids = notifications.unread.ordered.limit(100).pluck(:id) + notifications.read.ordered.limit(100).pluck(:id) - get tray_notifications_path(format: :json, include_unread: true) + get tray_notifications_path(format: :json, include_read: true) assert_response :success assert_equal expected_ids, @response.parsed_body.map { |s| s["id"] }