FIX: Allow us to serialize reviewables with deleted topics

FIX: Allow us to serialize reviewables with deleted topics

diff --git a/app/serializers/reviewable_serializer.rb b/app/serializers/reviewable_serializer.rb
index f6d3f23..a47ec79 100644
--- a/app/serializers/reviewable_serializer.rb
+++ b/app/serializers/reviewable_serializer.rb
@@ -93,7 +93,7 @@ class ReviewableSerializer < ApplicationSerializer
   end
 
   def include_topic_url?
-    object.topic_id.present?
+    object.topic.present?
   end
 
   def include_topic_id?
diff --git a/spec/serializers/reviewable_flagged_post_serializer_spec.rb b/spec/serializers/reviewable_flagged_post_serializer_spec.rb
index 2c43bcc..4f8b68f 100644
--- a/spec/serializers/reviewable_flagged_post_serializer_spec.rb
+++ b/spec/serializers/reviewable_flagged_post_serializer_spec.rb
@@ -13,4 +13,13 @@ describe ReviewableFlaggedPostSerializer do
     expect(json[:topic_url]).to eq(p0.url)
   end
 
+  it "works when the topic is deleted" do
+    reviewable = Fabricate(:reviewable_queued_post)
+    reviewable.topic.update(deleted_at: Time.now)
+    reviewable.reload
+
+    json = ReviewableQueuedPostSerializer.new(reviewable, scope: Guardian.new(admin), root: nil).as_json
+    expect(json[:id]).to be_present
+  end
+
 end

GitHub sha: af04318a

This commit has been mentioned on Discourse Meta. There might be relevant details there: