FIX: Blocked watched words should apply to staff (#7547)

Having different behavior for staff and regular users can make it confusing for admins to understand how their configuration changes affect regular users
This commit is contained in:
David Taylor 2019-05-16 15:19:41 +01:00 committed by GitHub
parent ad4d01233b
commit b5dd4478e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 9 deletions

View File

@ -60,7 +60,7 @@ class Validators::PostValidator < ActiveModel::Validator
end
def watched_words(post)
if !post.acting_user&.staff? && !post.acting_user&.staged && matches = WordWatcher.new(post.raw).should_block?
if !post.acting_user&.staged && matches = WordWatcher.new(post.raw).should_block?
post.errors.add(:base, I18n.t('contains_blocked_words', word: matches[0]))
end
end

View File

@ -37,18 +37,14 @@ describe WatchedWord do
should_block_post(manager)
end
it "should not block the post from admin" do
it "should block the post from admin" do
manager = NewPostManager.new(admin, raw: "Want some #{block_word.word} for cheap?", topic_id: topic.id)
result = manager.perform
expect(result).to be_success
expect(result.action).to eq(:create_post)
should_block_post(manager)
end
it "should not block the post from moderator" do
it "should block the post from moderator" do
manager = NewPostManager.new(moderator, raw: "Want some #{block_word.word} for cheap?", topic_id: topic.id)
result = manager.perform
expect(result).to be_success
expect(result.action).to eq(:create_post)
should_block_post(manager)
end
it "should block in a private message too" do