FIX: ProcessPost job failed for posts that have no user
This commit is contained in:
parent
727a45185d
commit
7b58afe677
|
@ -38,7 +38,7 @@ module Jobs
|
|||
end
|
||||
end
|
||||
|
||||
if !post.user.staff? && !post.user.staged
|
||||
if !post.user&.staff? && !post.user&.staged?
|
||||
s = post.cooked
|
||||
s << " #{post.topic.title}" if post.post_number == 1
|
||||
if !args[:bypass_bump] && WordWatcher.new(s).should_flag?
|
||||
|
|
|
@ -62,6 +62,19 @@ describe Jobs::ProcessPost do
|
|||
expect { Jobs::ProcessPost.new.execute(post_id: post.id) }.to change { TopicLink.count }.by(2)
|
||||
end
|
||||
|
||||
it "works for posts that belong to no existing user" do
|
||||
cooked = post.cooked
|
||||
|
||||
post.update_columns(cooked: "frogs", user_id: nil)
|
||||
Jobs::ProcessPost.new.execute(post_id: post.id, cook: true)
|
||||
post.reload
|
||||
expect(post.cooked).to eq(cooked)
|
||||
|
||||
post.update_columns(cooked: "frogs", user_id: User.maximum("id") + 1)
|
||||
Jobs::ProcessPost.new.execute(post_id: post.id, cook: true)
|
||||
post.reload
|
||||
expect(post.cooked).to eq(cooked)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue