FEATURE: Silence watched word (#13160)

This is a new type of watched word to replace auto_silence_first_post_
regex site setting.
This commit is contained in:
Bianca Nenciu
2021-05-27 19:19:58 +03:00
committed by GitHub
parent 157f10db4c
commit 571ee4537a
6 changed files with 36 additions and 2 deletions

View File

@ -907,6 +907,28 @@ describe PostsController do
expect(user).to be_silenced
end
it 'silences correctly based on silence watched words' do
SiteSetting.watched_words_regular_expressions = true
WatchedWord.create!(action: WatchedWord.actions[:silence], word: 'I love candy')
WatchedWord.create!(action: WatchedWord.actions[:silence], word: 'i eat s[1-5]')
post "/posts.json", params: {
raw: 'this is the test content',
title: 'when I eat s3 sometimes when not looking'
}
expect(response.status).to eq(200)
parsed = response.parsed_body
expect(parsed["action"]).to eq("enqueued")
reviewable = ReviewableQueuedPost.find_by(created_by: user)
score = reviewable.reviewable_scores.first
expect(score.reason).to eq('auto_silence_regex')
user.reload
expect(user).to be_silenced
end
it "can send a message to a group" do
group = Group.create(name: 'test_group', messageable_level: Group::ALIAS_LEVELS[:nobody])
user1 = user