FIX: Typo in `NotificationsController#index` not caught by tests.
This commit is contained in:
parent
8dc3543134
commit
16961dee76
|
@ -25,7 +25,7 @@ class NotificationsController < ApplicationController
|
|||
notifications = 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 PMs
|
||||
max_id = notifications.map(&:id).max
|
||||
changed = current_user.saw_notification_id(max_id)
|
||||
|
|
|
@ -43,14 +43,23 @@ describe NotificationsController do
|
|||
end
|
||||
|
||||
it '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)
|
||||
end
|
||||
|
||||
it 'should mark notifications as viewed' do
|
||||
expect(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 do
|
|||
it 'should not mark notifications as viewed if silent param is present' do
|
||||
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)
|
||||
end
|
||||
|
@ -67,7 +79,10 @@ describe NotificationsController do
|
|||
Discourse.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 do
|
|||
expect(response.status).to eq(200)
|
||||
|
||||
get "/notifications.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['notifications'].length).to be >= 2
|
||||
|
||||
get "/notifications.json", params: { filter: "read" }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(JSON.parse(response.body)['notifications'].length).to be >= 1
|
||||
expect(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 >= 1
|
||||
expect(JSON.parse(response.body)['notifications'][0]['read']).to eq(false)
|
||||
end
|
||||
|
@ -120,7 +141,10 @@ describe NotificationsController do
|
|||
it "updates the `read` status" do
|
||||
expect(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.reload
|
||||
expect(user.reload.unread_notifications).to eq(0)
|
||||
expect(user.reload.total_unread_notifications).to eq(0)
|
||||
|
|
Loading…
Reference in New Issue