FIX: Don't try and reindex posts that have been trashed.

FIX: Don’t try and reindex posts that have been trashed.

diff --git a/app/jobs/scheduled/reindex_search.rb b/app/jobs/scheduled/reindex_search.rb
index 1a15ec5..5a1c784 100644
--- a/app/jobs/scheduled/reindex_search.rb
+++ b/app/jobs/scheduled/reindex_search.rb
@@ -95,9 +95,8 @@ module Jobs
           ON pd.locale = :locale
           AND pd.version = :version
           AND pd.post_id = posts.id
-        LEFT JOIN topics ON topics.id = posts.topic_id
+        INNER JOIN topics ON topics.id = posts.topic_id
         WHERE pd.post_id IS NULL
-        AND topics.id IS NOT NULL
         AND topics.deleted_at IS NULL
         AND posts.raw != ''
         ORDER BY posts.id DESC
diff --git a/spec/jobs/reindex_search_spec.rb b/spec/jobs/reindex_search_spec.rb
index df63466..bc6b3f6 100644
--- a/spec/jobs/reindex_search_spec.rb
+++ b/spec/jobs/reindex_search_spec.rb
@@ -49,12 +49,16 @@ describe Jobs::ReindexSearch do
       FakeIndexer.reset
     end
 
-    it 'should not reinex posts that belong to a deleted topic' do
+    it (
+      'should not reindex posts that belong to a deleted topic ' \
+      'or have been trashed'
+    ) do
       post = Fabricate(:post)
       post2 = Fabricate(:post)
-      post.post_search_data.destroy!
-      post2.post_search_data.destroy!
+      post3 = Fabricate(:post)
+      PostSearchData.delete_all
       post2.topic.trash!
+      post3.trash!
 
       subject.rebuild_problem_posts(indexer: FakeIndexer)

GitHub sha: c4997ce8