diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index 0c35f70b0a7..874c8628394 100644 --- a/lib/pretty_text.rb +++ b/lib/pretty_text.rb @@ -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 diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rb index c30be629f6b..63e2eca471f 100644 --- a/spec/components/pretty_text_spec.rb +++ b/spec/components/pretty_text_spec.rb @@ -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("

#unknown::tag #known

") + end + + end + end