mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 17:36:27 +00:00
bugdown: Add custom per-realm filters to linkify certain strings.
I've tried to do this in a way that's scalable and easily configured, so that we can add new such filters for customers on-demand without needing to add anything other than a bit of configuration. Once we're confident in the arguments to this system, I think we'll want to move the regular expression lists into the database so that we don't need to do a prod push to modify the regular expression lists. The initial set of regular expressions are: (1) Linkifying e.g. "trac #224" in the Humbug realm, so we're exercising this code. (2) The various ticket number things CUSTOMER7 uses for the CUSTOMER7 realm. (imported from commit 992b0937b9012c15a7c2f585eb0aacb221c52e01)
This commit is contained in:
@@ -1839,7 +1839,7 @@ class GetSubscribersTest(AuthedTestCase):
|
||||
"Unable to retrieve subscribers for invite-only stream")
|
||||
|
||||
def bugdown_convert(text):
|
||||
return bugdown.convert(text)
|
||||
return bugdown.convert(text, "humbughq.com")
|
||||
|
||||
class BugdownTest(TestCase):
|
||||
def common_bugdown_test(self, text, expected):
|
||||
@@ -2310,6 +2310,12 @@ But you can never leave**"""
|
||||
converted = bugdown_convert(msg)
|
||||
self.assertEqual(converted, "<p>You can check out **any time you'd like<br>\nBut you can never leave**</p>")
|
||||
|
||||
def test_realm_patterns(self):
|
||||
msg = "We should fix trac #224 and Trac #115, but not Ztrac #124 or trac #1124Z today."
|
||||
converted = bugdown_convert(msg)
|
||||
|
||||
self.assertEqual(converted, '<p>We should fix <a href="https://trac.humbughq.com/ticket/224" target="_blank" title="https://trac.humbughq.com/ticket/224">trac #224</a> and <a href="https://trac.humbughq.com/ticket/115" target="_blank" title="https://trac.humbughq.com/ticket/115">Trac #115</a>, but not Ztrac #124 or trac #1124Z today.</p>')
|
||||
|
||||
class UserPresenceTests(AuthedTestCase):
|
||||
fixtures = ['messages.json']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user