dtext links: add table for tracking links between wikis.

Add a dtext_links table for tracking links between wiki pages. This is
to allow for broken link detection and "what links here" searches, among
other uses.
This commit is contained in:
evazion
2019-10-23 14:23:03 -05:00
parent f54885b72e
commit 9f0ecf7247
7 changed files with 178 additions and 1 deletions

View File

@@ -110,6 +110,21 @@ class WikiPageTest < ActiveSupport::TestCase
version = WikiPageVersion.last
assert_not_equal(@wiki_page.creator_id, version.updater_id)
end
should "update its dtext links" do
@wiki_page.update!(body: "[[long hair]]")
assert_equal(1, @wiki_page.dtext_links.size)
assert_equal("wiki_link", @wiki_page.dtext_links.first.link_type)
assert_equal("long_hair", @wiki_page.dtext_links.first.link_target)
@wiki_page.update!(body: "http://www.google.com")
assert_equal(1, @wiki_page.dtext_links.size)
assert_equal("external_link", @wiki_page.dtext_links.first.link_type)
assert_equal("http://www.google.com", @wiki_page.dtext_links.first.link_target)
@wiki_page.update!(body: "nothing")
assert_equal(0, @wiki_page.dtext_links.size)
end
end
end
end