mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 09:26:54 -06:00
FIX: Check if post.topic exists before publishing topic updates (#11900)
This commit is contained in:
parent
fcdf7ef019
commit
f4db1675f3
@ -6,7 +6,7 @@ module Jobs
|
||||
def execute(args)
|
||||
post = Post.find_by(id: args[:post_id])
|
||||
|
||||
if post
|
||||
if post && post.topic
|
||||
TopicTrackingState.publish_unmuted(post.topic)
|
||||
if post.post_number > 1
|
||||
TopicTrackingState.publish_muted(post.topic)
|
||||
|
18
spec/jobs/post_update_topic_tracking_state_spec.rb
Normal file
18
spec/jobs/post_update_topic_tracking_state_spec.rb
Normal file
@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Jobs::PostUpdateTopicTrackingState do
|
||||
fab!(:post) { Fabricate(:post) }
|
||||
|
||||
it 'should publish messages' do
|
||||
messages = MessageBus.track_publish { subject.execute({ post_id: post.id }) }
|
||||
expect(messages.size).not_to eq(0)
|
||||
end
|
||||
|
||||
it 'should not publish messages for deleted topics' do
|
||||
post.topic.trash!
|
||||
messages = MessageBus.track_publish { subject.execute({ post_id: post.id }) }
|
||||
expect(messages.size).to eq(0)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user