From 5c2e90954384930296e548fb4d9366ca36a30eca Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Wed, 3 Aug 2022 18:23:43 +0300 Subject: [PATCH] DEV: Don't publish to the `/reviewable_counts` channel (#17779) Follow-up to https://github.com/discourse/discourse/commit/ce9eec8606e6c55ef6fa09b630464067fcea7b43. I did a last-minute refactoring before merging the commit above where I extracted the Message Bus publish call into a new method, but forgot to delete the publish call after adding a call to the new method. --- app/models/user.rb | 5 ----- spec/models/user_spec.rb | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 319221e209e..d7678e1ccb0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -643,11 +643,6 @@ class User < ActiveRecord::Base if max_reviewable_id update!(last_seen_reviewable_id: max_reviewable_id) publish_reviewable_counts(unseen_reviewable_count: self.unseen_reviewable_count) - MessageBus.publish( - "/reviewable_counts", - { unseen_reviewable_count: self.unseen_reviewable_count }, - user_ids: [self.id] - ) end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 0ff81b202d3..2d0d6d937fd 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -2905,5 +2905,19 @@ RSpec.describe User do expect(moderator.last_seen_reviewable_id).to eq(mod_reviewable.id) expect(user.last_seen_reviewable_id).to eq(group_reviewable.id) end + + it "publishes a message to the user's /reviewable_counts message bus channel" do + user.update!(admin: true) + Fabricate(:reviewable) + messages = MessageBus.track_publish do + user.bump_last_seen_reviewable! + end + expect(messages.size).to eq(1) + expect(messages.first).to have_attributes( + channel: "/reviewable_counts/#{user.id}", + user_ids: [user.id], + data: { unseen_reviewable_count: 0 } + ) + end end end