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
|
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 :fast_typer if is_fast_typer?(manager)
|
||||||
|
|
||||||
return :auto_silence_regex if matches_auto_silence_regex?(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 :staged if SiteSetting.approve_unless_staged? && user.staged?
|
||||||
|
|
||||||
return :category if post_needs_approval_in_its_category?(manager)
|
return :category if post_needs_approval_in_its_category?(manager)
|
||||||
|
|
|
@ -209,7 +209,6 @@ describe NewPostManager do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a fast typer' do
|
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 }
|
let(:user) { manager.user }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -217,12 +216,27 @@ describe NewPostManager do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "adds the silence reason in the system locale" do
|
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
|
I18n.with_locale(:fr) do # Simulate french user
|
||||||
result = NewPostManager.default_handler(manager)
|
result = NewPostManager.default_handler(manager)
|
||||||
end
|
end
|
||||||
expect(user.silenced?).to eq(true)
|
expect(user.silenced?).to eq(true)
|
||||||
expect(user.silence_reason).to eq(I18n.t("user.new_user_typed_too_fast", locale: :en))
|
expect(user.silence_reason).to eq(I18n.t("user.new_user_typed_too_fast", locale: :en))
|
||||||
end
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue