Merge pull request #2874 from cpradio/clear-notifications

FEATURE: Mark All as Read button for Notifications page
This commit is contained in:
Robin Ward
2014-10-16 15:57:19 -04:00
11 changed files with 88 additions and 1 deletions
@@ -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
+10
View File
@@ -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