A platform for community discussion. Free, open, simple.
FIX: Blocked watched words should apply to staff (#7547)
David Taylorb5dd4478e524
diff --git a/lib/validators/post_validator.rb b/lib/validators/post_validator.rbindex e566e006a72..d5a33a79bb5 100644--- a/lib/validators/post_validator.rb+++ b/lib/validators/post_validator.rb@@ -60,7 +60,7 @@ class Validators::PostValidator < ActiveModel::Validatorenddef 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]))endenddiff --git a/spec/integration/watched_words_spec.rb b/spec/integration/watched_words_spec.rbindex d8d127ef260..2e3853be08e 100644--- a/spec/integration/watched_words_spec.rb+++ b/spec/integration/watched_words_spec.rb@@ -37,18 +37,14 @@ describe WatchedWord doshould_block_post(manager)end- it "should not block the post from admin" do+ it "should block the post from admin" domanager = 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" domanager = 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)endit "should block in a private message too" do