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)
|
notifications = Notification.recent_report(current_user, limit)
|
||||||
changed = false
|
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
|
# ordering can be off due to PMs
|
||||||
max_id = notifications.map(&:id).max
|
max_id = notifications.map(&:id).max
|
||||||
changed = current_user.saw_notification_id(max_id)
|
changed = current_user.saw_notification_id(max_id)
|
||||||
|
|
|
@ -43,14 +43,23 @@ describe NotificationsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should succeed for history' do
|
it 'should succeed for history' do
|
||||||
get "/notifications"
|
get "/notifications.json"
|
||||||
|
|
||||||
expect(response.status).to eq(200)
|
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
|
end
|
||||||
|
|
||||||
it 'should mark notifications as viewed' do
|
it 'should mark notifications as viewed' do
|
||||||
expect(user.reload.unread_notifications).to eq(1)
|
expect(user.reload.unread_notifications).to eq(1)
|
||||||
expect(user.reload.total_unread_notifications).to eq(1)
|
expect(user.reload.total_unread_notifications).to eq(1)
|
||||||
|
|
||||||
get "/notifications.json", params: { recent: true }
|
get "/notifications.json", params: { recent: true }
|
||||||
|
|
||||||
|
expect(response.status).to eq(200)
|
||||||
expect(user.reload.unread_notifications).to eq(0)
|
expect(user.reload.unread_notifications).to eq(0)
|
||||||
expect(user.reload.total_unread_notifications).to eq(1)
|
expect(user.reload.total_unread_notifications).to eq(1)
|
||||||
end
|
end
|
||||||
|
@ -58,7 +67,10 @@ describe NotificationsController do
|
||||||
it 'should not mark notifications as viewed if silent param is present' 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.unread_notifications).to eq(1)
|
||||||
expect(user.reload.total_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.unread_notifications).to eq(1)
|
||||||
expect(user.reload.total_unread_notifications).to eq(1)
|
expect(user.reload.total_unread_notifications).to eq(1)
|
||||||
end
|
end
|
||||||
|
@ -67,7 +79,10 @@ describe NotificationsController do
|
||||||
Discourse.received_redis_readonly!
|
Discourse.received_redis_readonly!
|
||||||
expect(user.reload.unread_notifications).to eq(1)
|
expect(user.reload.unread_notifications).to eq(1)
|
||||||
expect(user.reload.total_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.unread_notifications).to eq(1)
|
||||||
expect(user.reload.total_unread_notifications).to eq(1)
|
expect(user.reload.total_unread_notifications).to eq(1)
|
||||||
ensure
|
ensure
|
||||||
|
@ -81,13 +96,19 @@ describe NotificationsController do
|
||||||
expect(response.status).to eq(200)
|
expect(response.status).to eq(200)
|
||||||
|
|
||||||
get "/notifications.json"
|
get "/notifications.json"
|
||||||
|
|
||||||
|
expect(response.status).to eq(200)
|
||||||
expect(JSON.parse(response.body)['notifications'].length).to be >= 2
|
expect(JSON.parse(response.body)['notifications'].length).to be >= 2
|
||||||
|
|
||||||
get "/notifications.json", params: { filter: "read" }
|
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'].length).to be >= 1
|
||||||
expect(JSON.parse(response.body)['notifications'][0]['read']).to eq(true)
|
expect(JSON.parse(response.body)['notifications'][0]['read']).to eq(true)
|
||||||
|
|
||||||
get "/notifications.json", params: { filter: "unread" }
|
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'].length).to be >= 1
|
||||||
expect(JSON.parse(response.body)['notifications'][0]['read']).to eq(false)
|
expect(JSON.parse(response.body)['notifications'][0]['read']).to eq(false)
|
||||||
end
|
end
|
||||||
|
@ -120,7 +141,10 @@ describe NotificationsController do
|
||||||
it "updates the `read` status" do
|
it "updates the `read` status" do
|
||||||
expect(user.reload.unread_notifications).to eq(1)
|
expect(user.reload.unread_notifications).to eq(1)
|
||||||
expect(user.reload.total_unread_notifications).to eq(1)
|
expect(user.reload.total_unread_notifications).to eq(1)
|
||||||
|
|
||||||
put "/notifications/mark-read.json"
|
put "/notifications/mark-read.json"
|
||||||
|
|
||||||
|
expect(response.status).to eq(200)
|
||||||
user.reload
|
user.reload
|
||||||
expect(user.reload.unread_notifications).to eq(0)
|
expect(user.reload.unread_notifications).to eq(0)
|
||||||
expect(user.reload.total_unread_notifications).to eq(0)
|
expect(user.reload.total_unread_notifications).to eq(0)
|
||||||
|
|
Loading…
Reference in New Issue