Return full URLs in review serializer for both post and topic

Return full URLs, this fixes reviewable links to support subfolder
This commit is contained in:
Jeff Wong 2019-11-14 15:57:24 -08:00
parent 3b16eb7abb
commit 786fcceb62
2 changed files with 2 additions and 2 deletions

View File

@ -106,7 +106,7 @@ class ReviewableSerializer < ApplicationSerializer
end end
def target_url def target_url
return object.target.url if object.target.is_a?(Post) && object.target.present? return Discourse.base_url + object.target.url if object.target.is_a?(Post) && object.target.present?
topic_url topic_url
end end

View File

@ -37,7 +37,7 @@ describe ReviewableSerializer do
it "links to the flagged post" do it "links to the flagged post" do
fp = Fabricate(:reviewable_flagged_post) fp = Fabricate(:reviewable_flagged_post)
json = described_class.new(fp, scope: Guardian.new(admin), root: nil).as_json json = described_class.new(fp, scope: Guardian.new(admin), root: nil).as_json
expect(json[:target_url]).to eq(fp.post.url) expect(json[:target_url]).to eq(Discourse.base_url + fp.post.url)
expect(json[:topic_url]).to eq(fp.topic.url) expect(json[:topic_url]).to eq(fp.topic.url)
end end