A platform for community discussion. Free, open, simple.
FIX: Reload only notifications when refreshing notification count (#8221)
Dan Ungureanu3ad07aacfaab
diff --git a/app/models/notification.rb b/app/models/notification.rbindex 6a4413e7f5b..4f300f81380 100644--- a/app/models/notification.rb+++ b/app/models/notification.rb@@ -218,7 +218,8 @@ class Notification < ActiveRecord::Basedef refresh_notification_countbegin- user.reload.publish_notifications_state+ user.notifications.reset+ user.publish_notifications_staterescue ActiveRecord::RecordNotFound# happens when we delete a userenddiff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rbindex 29dcad458ba..8055ad48a0e 100644--- a/spec/models/user_spec.rb+++ b/spec/models/user_spec.rb@@ -1821,7 +1821,7 @@ describe User dolet!(:staged_user) { Fabricate(:staged, email: '[email protected]', active: true, username: 'staged1', name: 'Stage Name') }let(:params) { { email: '[email protected]', active: true, username: 'unstaged1', name: 'Foo Bar' } }- it "correctyl unstages a user" do+ it "correctly unstages a user" douser = User.unstage(params)expect(user.id).to eq(staged_user.id)@@ -1829,6 +1829,7 @@ describe User doexpect(user.name).to eq('Foo Bar')expect(user.active).to eq(false)expect(user.email).to eq('[email protected]')+ expect(user.staged).to eq(false)endit "returns nil when the user cannot be unstaged" do@@ -1838,13 +1839,14 @@ describe User doendit "removes all previous notifications during unstaging" do- Fabricate(:notification, user: user)- Fabricate(:private_message_notification, user: user)- user.reload+ Fabricate(:notification, user: staged_user)+ Fabricate(:private_message_notification, user: staged_user)+ staged_user.reload- expect(user.total_unread_notifications).to eq(2)+ expect(staged_user.total_unread_notifications).to eq(2)user = User.unstage(params)expect(user.total_unread_notifications).to eq(0)+ expect(user.staged).to eq(false)endit "triggers an event" do