A platform for community discussion. Free, open, simple.
FIX: Typo in `NotificationsController#index` not caught by tests.
Guo Xiang Tan16961dee7655
diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rbindex 1d28fb4caf0..baa9aca3a43 100644--- a/app/controllers/notifications_controller.rb+++ b/app/controllers/notifications_controller.rb@@ -25,7 +25,7 @@ class NotificationsController < ApplicationControllernotifications = Notification.recent_report(current_user, limit)changed = false- if notifications.present? && !(params.has_key?(:slient) || @readonly_mode)+ if notifications.present? && !(params.has_key?(:silent) || @readonly_mode)# ordering can be off due to PMsmax_id = notifications.map(&:id).maxchanged = current_user.saw_notification_id(max_id)diff --git a/spec/requests/notifications_controller_spec.rb b/spec/requests/notifications_controller_spec.rbindex 495ae5afbe5..3e903280f89 100644--- a/spec/requests/notifications_controller_spec.rb+++ b/spec/requests/notifications_controller_spec.rb@@ -43,14 +43,23 @@ describe NotificationsController doendit 'should succeed for history' do- get "/notifications"+ get "/notifications.json"+expect(response.status).to eq(200)++ notifications = response.parsed_body["notifications"]++ expect(notifications.length).to eq(1)+ expect(notifications.first["id"]).to eq(notification.id)endit 'should mark notifications as viewed' doexpect(user.reload.unread_notifications).to eq(1)expect(user.reload.total_unread_notifications).to eq(1)+get "/notifications.json", params: { recent: true }++ expect(response.status).to eq(200)expect(user.reload.unread_notifications).to eq(0)expect(user.reload.total_unread_notifications).to eq(1)end@@ -58,7 +67,10 @@ describe NotificationsController doit 'should not mark notifications as viewed if silent param is present' doexpect(user.reload.unread_notifications).to eq(1)expect(user.reload.total_unread_notifications).to eq(1)- get "/notifications", params: { recent: true, silent: true }++ get "/notifications.json", params: { recent: true, silent: true }++ expect(response.status).to eq(200)expect(user.reload.unread_notifications).to eq(1)expect(user.reload.total_unread_notifications).to eq(1)end@@ -67,7 +79,10 @@ describe NotificationsController doDiscourse.received_redis_readonly!expect(user.reload.unread_notifications).to eq(1)expect(user.reload.total_unread_notifications).to eq(1)- get "/notifications", params: { recent: true, silent: true }++ get "/notifications.json", params: { recent: true, silent: true }++ expect(response.status).to eq(200)expect(user.reload.unread_notifications).to eq(1)expect(user.reload.total_unread_notifications).to eq(1)ensure@@ -81,13 +96,19 @@ describe NotificationsController doexpect(response.status).to eq(200)get "/notifications.json"++ expect(response.status).to eq(200)expect(JSON.parse(response.body)['notifications'].length).to be >= 2get "/notifications.json", params: { filter: "read" }++ expect(response.status).to eq(200)expect(JSON.parse(response.body)['notifications'].length).to be >= 1expect(JSON.parse(response.body)['notifications'][0]['read']).to eq(true)get "/notifications.json", params: { filter: "unread" }++ expect(response.status).to eq(200)expect(JSON.parse(response.body)['notifications'].length).to be >= 1expect(JSON.parse(response.body)['notifications'][0]['read']).to eq(false)end@@ -120,7 +141,10 @@ describe NotificationsController doit "updates the `read` status" doexpect(user.reload.unread_notifications).to eq(1)expect(user.reload.total_unread_notifications).to eq(1)+put "/notifications/mark-read.json"++ expect(response.status).to eq(200)user.reloadexpect(user.reload.unread_notifications).to eq(0)expect(user.reload.total_unread_notifications).to eq(0)