mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: We should check for watched words first even if the user is a fast typer. (#10630)
This commit is contained in:
parent
24cd3e2c2c
commit
cac64a95aa
|
@ -98,12 +98,12 @@ class NewPostManager
|
|||
user.trust_level < SiteSetting.approve_new_topics_unless_trust_level.to_i
|
||||
)
|
||||
|
||||
return :watched_word if WordWatcher.new("#{manager.args[:title]} #{manager.args[:raw]}").requires_approval?
|
||||
|
||||
return :fast_typer if is_fast_typer?(manager)
|
||||
|
||||
return :auto_silence_regex if matches_auto_silence_regex?(manager)
|
||||
|
||||
return :watched_word if WordWatcher.new("#{manager.args[:title]} #{manager.args[:raw]}").requires_approval?
|
||||
|
||||
return :staged if SiteSetting.approve_unless_staged? && user.staged?
|
||||
|
||||
return :category if post_needs_approval_in_its_category?(manager)
|
||||
|
|
|
@ -209,7 +209,6 @@ describe NewPostManager do
|
|||
end
|
||||
|
||||
context 'with a fast typer' do
|
||||
let(:manager) { NewPostManager.new(topic.user, raw: 'this is new post content', topic_id: topic.id, first_post_checks: true) }
|
||||
let(:user) { manager.user }
|
||||
|
||||
before do
|
||||
|
@ -217,12 +216,27 @@ describe NewPostManager do
|
|||
end
|
||||
|
||||
it "adds the silence reason in the system locale" do
|
||||
manager = build_manager_with('this is new post content')
|
||||
I18n.with_locale(:fr) do # Simulate french user
|
||||
result = NewPostManager.default_handler(manager)
|
||||
end
|
||||
expect(user.silenced?).to eq(true)
|
||||
expect(user.silence_reason).to eq(I18n.t("user.new_user_typed_too_fast", locale: :en))
|
||||
end
|
||||
|
||||
it 'runs the watched words check before checking if the user is a fast typer' do
|
||||
Fabricate(:watched_word, word: "darn", action: WatchedWord.actions[:require_approval])
|
||||
manager = build_manager_with('this is darn new post content')
|
||||
|
||||
result = NewPostManager.default_handler(manager)
|
||||
|
||||
expect(result.action).to eq(:enqueued)
|
||||
expect(result.reason).to eq(:watched_word)
|
||||
end
|
||||
|
||||
def build_manager_with(raw)
|
||||
NewPostManager.new(topic.user, raw: raw, topic_id: topic.id, first_post_checks: true)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user