FIX: Make replace watched words work with wildcard (#13084)

Watched words are always regular expressions, despite watched_words_
_regular_expressions being enabled or not. Internally, wildcard
characters are replaced with a regular expression that matches any non
whitespace character.
This commit is contained in:
Bianca Nenciu
2021-05-18 12:09:47 +03:00
committed by GitHub
parent a21700a444
commit c1dfd76658
5 changed files with 35 additions and 48 deletions
+9 -1
View File
@@ -1401,11 +1401,19 @@ HTML
after(:all) { Discourse.redis.flushdb }
it "replaces words with other words" do
Fabricate(:watched_word, action: WatchedWord.actions[:replace], word: "dolor sit", replacement: "something else")
Fabricate(:watched_word, action: WatchedWord.actions[:replace], word: "dolor sit*", replacement: "something else")
expect(PrettyText.cook("Lorem ipsum dolor sit amet")).to match_html(<<~HTML)
<p>Lorem ipsum something else amet</p>
HTML
expect(PrettyText.cook("Lorem ipsum dolor sits amet")).to match_html(<<~HTML)
<p>Lorem ipsum something else amet</p>
HTML
expect(PrettyText.cook("Lorem ipsum dolor sittt amet")).to match_html(<<~HTML)
<p>Lorem ipsum something else amet</p>
HTML
end
it "replaces words with links" do