mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 23:36:11 +08:00
FEATURE: Validate tags in WatchedWords (#17254)
* FEATURE: Validate tags in WatchedWords We didn't validate watched words automatic tagging, so it was possible for an admin to created watched words with an empty tag list which would result in an exception when users tried to create a new topic that matched the misconfigured watched word. Bug report: https://meta.discourse.org/t/lib-topic-creator-fails-when-the-word-math-appears-in-the-topic-title-or-text/231018?u=falco
This commit is contained in:

committed by
GitHub

parent
64adf3cba3
commit
f56c44d1c7
@ -89,6 +89,12 @@ describe WatchedWord do
|
||||
}.to_not change { described_class.count }
|
||||
end
|
||||
|
||||
it "error when an tag action is created without valid tags" do
|
||||
expect {
|
||||
described_class.create!(word: "ramones", action: described_class.actions[:tag])
|
||||
}.to raise_error(ActiveRecord::RecordInvalid)
|
||||
end
|
||||
|
||||
it "replaces link with absolute URL" do
|
||||
word = Fabricate(:watched_word, action: described_class.actions[:link], word: "meta1")
|
||||
expect(word.replacement).to eq("http://test.localhost/")
|
||||
|
Reference in New Issue
Block a user