Commit 59122560 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'cablett-conditional-allow-spam' into 'master'

Decouple reCAPTCHA from conditional allow

See merge request gitlab-org/gitlab!32805
parents fd40e9ec 7bf9acb8
......@@ -49,7 +49,8 @@ module Spam
# ask the SpamVerdictService what to do with the target.
spam_verdict_service.execute.tap do |result|
case result
when REQUIRE_RECAPTCHA
when CONDITIONAL_ALLOW
# at the moment, this means "ask for reCAPTCHA"
create_spam_log(api)
break if target.allow_possible_spam?
......
......@@ -2,7 +2,7 @@
module Spam
module SpamConstants
REQUIRE_RECAPTCHA = "recaptcha"
CONDITIONAL_ALLOW = "conditional_allow"
DISALLOW = "disallow"
ALLOW = "allow"
BLOCK_USER = "block"
......@@ -14,7 +14,7 @@ module Spam
DISALLOW => {
priority: 2
},
REQUIRE_RECAPTCHA => {
CONDITIONAL_ALLOW => {
priority: 3
},
ALLOW => {
......
......@@ -31,7 +31,7 @@ module Spam
def akismet_verdict
if akismet.spam?
Gitlab::Recaptcha.enabled? ? REQUIRE_RECAPTCHA : DISALLOW
Gitlab::Recaptcha.enabled? ? CONDITIONAL_ALLOW : DISALLOW
else
ALLOW
end
......
......@@ -536,7 +536,7 @@ describe Projects::IssuesController do
before do
stub_application_setting(recaptcha_enabled: true)
expect_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
expect(verdict_service).to receive(:execute).and_return(REQUIRE_RECAPTCHA)
expect(verdict_service).to receive(:execute).and_return(CONDITIONAL_ALLOW)
end
end
......@@ -851,7 +851,7 @@ describe Projects::IssuesController do
context 'when recaptcha is not verified' do
before do
expect_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
expect(verdict_service).to receive(:execute).and_return(REQUIRE_RECAPTCHA)
expect(verdict_service).to receive(:execute).and_return(CONDITIONAL_ALLOW)
end
end
......@@ -1103,7 +1103,7 @@ describe Projects::IssuesController do
context 'when captcha is not verified' do
before do
expect_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
expect(verdict_service).to receive(:execute).and_return(REQUIRE_RECAPTCHA)
expect(verdict_service).to receive(:execute).and_return(CONDITIONAL_ALLOW)
end
end
......
......@@ -81,7 +81,7 @@ describe 'New issue', :js do
before do
allow_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
allow(verdict_service).to receive(:execute).and_return(REQUIRE_RECAPTCHA)
allow(verdict_service).to receive(:execute).and_return(CONDITIONAL_ALLOW)
end
visit new_project_issue_path(project)
......
......@@ -68,7 +68,7 @@ shared_examples_for 'snippet editor' do
context 'when SpamVerdictService requires recaptcha' do
before do
expect_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
expect(verdict_service).to receive(:execute).and_return(REQUIRE_RECAPTCHA)
expect(verdict_service).to receive(:execute).and_return(CONDITIONAL_ALLOW)
end
end
......
......@@ -458,7 +458,7 @@ describe Issues::CreateService do
context 'when SpamVerdictService requires reCAPTCHA' do
before do
expect_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
expect(verdict_service).to receive(:execute).and_return(REQUIRE_RECAPTCHA)
expect(verdict_service).to receive(:execute).and_return(CONDITIONAL_ALLOW)
end
end
......
......@@ -163,9 +163,9 @@ describe Spam::SpamActionService do
end
end
context 'when spam verdict service requires reCAPTCHA' do
context 'when spam verdict service conditionally allows' do
before do
allow(fake_verdict_service).to receive(:execute).and_return(REQUIRE_RECAPTCHA)
allow(fake_verdict_service).to receive(:execute).and_return(CONDITIONAL_ALLOW)
end
context 'when allow_possible_spam feature flag is false' do
......
......@@ -123,8 +123,8 @@ describe Spam::SpamVerdictService do
stub_application_setting(recaptcha_enabled: true)
end
it 'returns require reCAPTCHA verdict' do
expect(subject).to eq REQUIRE_RECAPTCHA
it 'returns conditionally allow verdict' do
expect(subject).to eq CONDITIONAL_ALLOW
end
end
......
......@@ -2,7 +2,7 @@
shared_context 'includes Spam constants' do
before do
stub_const('REQUIRE_RECAPTCHA', Spam::SpamConstants::REQUIRE_RECAPTCHA)
stub_const('CONDITIONAL_ALLOW', Spam::SpamConstants::CONDITIONAL_ALLOW)
stub_const('DISALLOW', Spam::SpamConstants::DISALLOW)
stub_const('ALLOW', Spam::SpamConstants::ALLOW)
stub_const('BLOCK_USER', Spam::SpamConstants::BLOCK_USER)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment