dtext: handle [bur:<id>] tags in main parser.
Move the parsing for the [bur:<id>], [ta:<id>], [ti:<id>] pseudo tags to the main parser in `DText.format_text`. This fixes a bug where wiki links inside bulk update requests on the forum weren't properly colorized because the text of the BUR was embedded after we scanned for wiki links, not before. This also ensures that tags inside bulk update requests will be recorded in the dtext_links table, meaning that forum posts can be properly searched by tags. This incidentally means that these request pseudo tags can now be used outside the forum.
This commit is contained in:
@@ -40,6 +40,16 @@ class DTextTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
context "#format_text" do
|
||||
setup do
|
||||
CurrentUser.user = create(:user)
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
end
|
||||
|
||||
teardown do
|
||||
CurrentUser.user = nil
|
||||
CurrentUser.ip_addr = nil
|
||||
end
|
||||
|
||||
should "add tag types to wiki links" do
|
||||
create(:tag, name: "bkub", category: Tag.categories.artist, post_count: 42)
|
||||
assert_match(/tag-type-#{Tag.categories.artist}/, DText.format_text("[[bkub]]"))
|
||||
@@ -55,6 +65,16 @@ class DTextTest < ActiveSupport::TestCase
|
||||
|
||||
refute_match(/dtext-tag-does-not-exist/, DText.format_text("[[help:nothing]]"))
|
||||
end
|
||||
|
||||
should "parse [ta:<id>], [ti:<id>], [bur:<id>] pseudo tags" do
|
||||
@bur = create(:bulk_update_request)
|
||||
@ti = create(:tag_implication)
|
||||
@ta = create(:tag_alias)
|
||||
|
||||
assert_match(/bulk update request/, DText.format_text("[bur:#{@bur.id}]"))
|
||||
assert_match(/implication ##{@ti.id}/, DText.format_text("[ti:#{@ti.id}]"))
|
||||
assert_match(/alias ##{@ta.id}/, DText.format_text("[ta:#{@ta.id}]"))
|
||||
end
|
||||
end
|
||||
|
||||
context "#parse_wiki_titles" do
|
||||
|
||||
Reference in New Issue
Block a user