mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 22:46:28 +08:00
Merge pull request #2425 from vikhyat/read-notifications-silently
Allow reading notifications without marking them as read
This commit is contained in:
commit
9007d96466
|
@ -8,7 +8,7 @@ class NotificationsController < ApplicationController
|
||||||
if notifications.present?
|
if notifications.present?
|
||||||
# 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
|
||||||
current_user.saw_notification_id(max_id)
|
current_user.saw_notification_id(max_id) unless params.has_key?(:silent)
|
||||||
end
|
end
|
||||||
current_user.reload
|
current_user.reload
|
||||||
current_user.publish_notifications_state
|
current_user.publish_notifications_state
|
||||||
|
|
|
@ -5,12 +5,24 @@ describe NotificationsController do
|
||||||
context 'when logged in' do
|
context 'when logged in' do
|
||||||
let!(:user) { log_in }
|
let!(:user) { log_in }
|
||||||
|
|
||||||
before do
|
it 'should succeed' do
|
||||||
xhr :get, :index
|
xhr :get, :index
|
||||||
|
response.should be_success
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { response }
|
it 'should mark notifications as viewed' do
|
||||||
it { should be_success }
|
notification = Fabricate(:notification, user: user)
|
||||||
|
user.reload.unread_notifications.should == 1
|
||||||
|
xhr :get, :index
|
||||||
|
user.reload.unread_notifications.should == 0
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not mark notifications as viewed if silent param is present' do
|
||||||
|
notification = Fabricate(:notification, user: user)
|
||||||
|
user.reload.unread_notifications.should == 1
|
||||||
|
xhr :get, :index, silent: true
|
||||||
|
user.reload.unread_notifications.should == 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when not logged in' do
|
context 'when not logged in' do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user