FIX: In reply to would sometimes have a broken link
This commit is contained in:
parent
5d7e34e0ad
commit
8c4e16eafd
|
@ -1,7 +1,7 @@
|
|||
<div class='post-topic'>
|
||||
{{#if reviewable.topic}}
|
||||
{{topic-status topic=reviewable.topic}}
|
||||
<a href={{reviewable.topic_url}} class='title-text'>{{reviewable.topic.title}}</a>
|
||||
<a href={{reviewable.target_url}} class='title-text'>{{reviewable.topic.title}}</a>
|
||||
{{category-badge reviewable.category}}
|
||||
{{reviewable-tags tags=reviewable.topic_tags tagName=''}}
|
||||
{{else if (has-block)}}
|
||||
|
|
|
@ -13,6 +13,7 @@ class ReviewableSerializer < ApplicationSerializer
|
|||
:type,
|
||||
:topic_id,
|
||||
:topic_url,
|
||||
:target_url,
|
||||
:topic_tags,
|
||||
:category_id,
|
||||
:created_at,
|
||||
|
@ -107,13 +108,21 @@ class ReviewableSerializer < ApplicationSerializer
|
|||
object.topic.present? && SiteSetting.tagging_enabled?
|
||||
end
|
||||
|
||||
def target_url
|
||||
return object.target.url if object.target.is_a?(Post) && object.target.present?
|
||||
topic_url
|
||||
end
|
||||
|
||||
def include_target_url?
|
||||
target_url.present?
|
||||
end
|
||||
|
||||
def topic_url
|
||||
return object.target.url if object.target.is_a?(Post)
|
||||
return object.topic.url
|
||||
return object.topic&.url
|
||||
end
|
||||
|
||||
def include_topic_url?
|
||||
object.topic.present?
|
||||
topic_url.present?
|
||||
end
|
||||
|
||||
def include_topic_id?
|
||||
|
|
|
@ -22,9 +22,7 @@ describe ReviewableSerializer do
|
|||
|
||||
it 'Includes the removed topic id when the topis was deleted' do
|
||||
reviewable.topic.trash!(admin)
|
||||
|
||||
json = described_class.new(reviewable.reload, scope: Guardian.new(admin), root: nil).as_json
|
||||
|
||||
expect(json[:removed_topic_id]).to eq reviewable.topic_id
|
||||
end
|
||||
|
||||
|
@ -33,4 +31,29 @@ describe ReviewableSerializer do
|
|||
json = ReviewableQueuedPostSerializer.new(reviewable, scope: Guardian.new(admin), root: nil).as_json
|
||||
expect(json['payload']).to be_blank
|
||||
end
|
||||
|
||||
describe "urls" do
|
||||
|
||||
it "links to the flagged post" do
|
||||
fp = Fabricate(:reviewable_flagged_post)
|
||||
json = described_class.new(fp, scope: Guardian.new(admin), root: nil).as_json
|
||||
expect(json[:target_url]).to eq(fp.post.url)
|
||||
expect(json[:topic_url]).to eq(fp.topic.url)
|
||||
end
|
||||
|
||||
it "supports deleted topics" do
|
||||
fp = Fabricate(:reviewable_flagged_post)
|
||||
fp.topic.trash!(admin)
|
||||
fp.reload
|
||||
|
||||
json = described_class.new(fp, scope: Guardian.new(admin), root: nil).as_json
|
||||
expect(json[:topic_url]).to be_blank
|
||||
end
|
||||
|
||||
it "links to the queued post" do
|
||||
json = described_class.new(reviewable, scope: Guardian.new(admin), root: nil).as_json
|
||||
expect(json[:target_url]).to eq(reviewable.topic.url)
|
||||
expect(json[:topic_url]).to eq(reviewable.topic.url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue