FIX: Don't run job if topic timer has already been deleted.

This commit is contained in:
Guo Xiang Tan 2017-11-30 15:26:26 +08:00
parent 853b51b519
commit c128e421c4
2 changed files with 1 additions and 8 deletions

View File

@ -2,7 +2,7 @@ module Jobs
class PublishTopicToCategory < Jobs::Base class PublishTopicToCategory < Jobs::Base
def execute(args) def execute(args)
topic_timer = TopicTimer.find_by(id: args[:topic_timer_id] || args[:topic_status_update_id]) topic_timer = TopicTimer.find_by(id: args[:topic_timer_id] || args[:topic_status_update_id])
raise Discourse::InvalidParameters.new(:topic_timer_id) if topic_timer.blank? return if topic_timer.blank?
topic = topic_timer.topic topic = topic_timer.topic
return if topic.blank? return if topic.blank?

View File

@ -20,13 +20,6 @@ RSpec.describe Jobs::PublishTopicToCategory do
SiteSetting.queue_jobs = true SiteSetting.queue_jobs = true
end end
describe 'when topic_timer_id is invalid' do
it 'should raise the right error' do
expect { described_class.new.execute(topic_timer_id: -1) }
.to raise_error(Discourse::InvalidParameters)
end
end
describe 'when topic has been deleted' do describe 'when topic has been deleted' do
it 'should not publish the topic to the new category' do it 'should not publish the topic to the new category' do
freeze_time 1.hour.ago freeze_time 1.hour.ago