mirror of
https://github.com/discourse/discourse.git
synced 2026-09-05 04:40:41 -05:00
Merge pull request #2874 from cpradio/clear-notifications
FEATURE: Mark All as Read button for Notifications page
This commit is contained in:
@@ -15,18 +15,37 @@ describe NotificationsController do
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'should succeed for history' do
|
||||
xhr :get, :reset_new
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'should mark notifications as viewed' do
|
||||
notification = Fabricate(:notification, user: user)
|
||||
user.reload.unread_notifications.should == 1
|
||||
user.reload.total_unread_notifications.should == 1
|
||||
xhr :get, :recent
|
||||
user.reload.unread_notifications.should == 0
|
||||
user.reload.total_unread_notifications.should == 1
|
||||
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
|
||||
user.reload.total_unread_notifications.should == 1
|
||||
xhr :get, :recent, silent: true
|
||||
user.reload.unread_notifications.should == 1
|
||||
user.reload.total_unread_notifications.should == 1
|
||||
end
|
||||
|
||||
it "updates the `read` status" do
|
||||
notification = Fabricate(:notification, user: user)
|
||||
user.reload.unread_notifications.should == 1
|
||||
user.reload.total_unread_notifications.should == 1
|
||||
xhr :put, :reset_new
|
||||
user.reload
|
||||
user.reload.unread_notifications.should == 0
|
||||
user.reload.total_unread_notifications.should == 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -78,6 +78,10 @@ describe Notification do
|
||||
lambda { Fabricate(:notification, user: user); user.reload }.should change(user, :unread_notifications)
|
||||
end
|
||||
|
||||
it 'increases total_unread_notifications' do
|
||||
lambda { Fabricate(:notification, user: user); user.reload }.should change(user, :total_unread_notifications)
|
||||
end
|
||||
|
||||
it "doesn't increase unread_private_messages" do
|
||||
lambda { Fabricate(:notification, user: user); user.reload }.should_not change(user, :unread_private_messages)
|
||||
end
|
||||
@@ -88,6 +92,10 @@ describe Notification do
|
||||
lambda { Fabricate(:private_message_notification, user: user); user.reload }.should_not change(user, :unread_notifications)
|
||||
end
|
||||
|
||||
it 'increases total_unread_notifications' do
|
||||
lambda { Fabricate(:notification, user: user); user.reload }.should change(user, :total_unread_notifications)
|
||||
end
|
||||
|
||||
it "increases unread_private_messages" do
|
||||
lambda { Fabricate(:private_message_notification, user: user); user.reload }.should change(user, :unread_private_messages)
|
||||
end
|
||||
@@ -141,6 +149,7 @@ describe Notification do
|
||||
it 'should create and rollup private message notifications' do
|
||||
@target.notifications.first.notification_type.should == Notification.types[:private_message]
|
||||
@post.user.unread_notifications.should == 0
|
||||
@post.user.total_unread_notifications.should == 0
|
||||
@target.unread_private_messages.should == 1
|
||||
|
||||
Fabricate(:post, topic: @topic, user: @topic.user)
|
||||
@@ -197,6 +206,7 @@ describe Notification do
|
||||
user.reload
|
||||
|
||||
user.unread_notifications.should == 0
|
||||
user.total_unread_notifications.should == 2
|
||||
user.unread_private_messages.should == 1
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user