FIX: Allow us to serialize reviewables with deleted topics

This commit is contained in:
Robin Ward 2019-04-02 09:36:25 -04:00
parent 02d8931425
commit af04318aff
2 changed files with 10 additions and 1 deletions

View File

@ -93,7 +93,7 @@ class ReviewableSerializer < ApplicationSerializer
end
def include_topic_url?
object.topic_id.present?
object.topic.present?
end
def include_topic_id?

View File

@ -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