Skip to content

Commit

Permalink
FIX: Blocked watched words should apply to staff (discourse#7547)
Browse files Browse the repository at this point in the history
Having different behavior for staff and regular users can make it confusing for admins to understand how their configuration changes affect regular users
  • Loading branch information
davidtaylorhq authored May 16, 2019
1 parent ad4d012 commit b5dd447
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/validators/post_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def raw_quality(post)
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
Expand Down
12 changes: 4 additions & 8 deletions spec/integration/watched_words_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,14 @@ def should_block_post(manager)
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
Expand Down

0 comments on commit b5dd447

Please sign in to comment.