FIX: Post does not save if it contains a tag link
This commit is contained in:
parent
ad2a3ec5bc
commit
d25dc126f7
|
@ -3,6 +3,7 @@ require 'nokogiri'
|
|||
require_dependency 'url_helper'
|
||||
require_dependency 'excerpt_parser'
|
||||
require_dependency 'post'
|
||||
require_dependency 'discourse_tagging'
|
||||
|
||||
module PrettyText
|
||||
|
||||
|
@ -74,7 +75,7 @@ module PrettyText
|
|||
|
||||
if !is_tag && category = Category.query_from_hashtag_slug(text)
|
||||
[category.url_with_id, text]
|
||||
elsif is_tag && tag = TopicCustomField.find_by(name: TAGS_FIELD_NAME, value: text.gsub!("#{tag_postfix}", ''))
|
||||
elsif is_tag && tag = TopicCustomField.find_by(name: DiscourseTagging::TAGS_FIELD_NAME, value: text.gsub!("#{tag_postfix}", ''))
|
||||
["#{Discourse.base_url}/tags/#{tag.value}", text]
|
||||
else
|
||||
nil
|
||||
|
|
|
@ -421,4 +421,15 @@ HTML
|
|||
end
|
||||
end
|
||||
|
||||
describe "tag and category links" do
|
||||
|
||||
it "produces tag links" do
|
||||
# TODO where is our tags table?
|
||||
TopicCustomField.create!(topic_id: 1, name: DiscourseTagging::TAGS_FIELD_NAME, value: "known")
|
||||
# TODO does it make sense to generate hashtags for tags that are missing in action?
|
||||
expect(PrettyText.cook(" #unknown::tag #known::tag")).to match_html("<p> <span class=\"hashtag\">#unknown::tag</span> <a class=\"hashtag\" href=\"http://test.localhost/tags/known\">#<span>known</span></a></p>")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue