Commit f8036bfc authored by Jan Provaznik's avatar Jan Provaznik

Merge branch '214738-cablett-remove-spam-flag-recaptcha' into 'master'

Remove Spam flag when needing reCAPTCHA

See merge request gitlab-org/gitlab!30022
parents 1fa35c64 3cab1081
...@@ -49,9 +49,6 @@ module Spam ...@@ -49,9 +49,6 @@ module Spam
break if target.allow_possible_spam? break if target.allow_possible_spam?
# TODO: remove spam! declaration
# https://gitlab.com/gitlab-org/gitlab/-/issues/214738
target.spam!
target.needs_recaptcha! target.needs_recaptcha!
when DISALLOW when DISALLOW
# TODO: remove `unless target.allow_possible_spam?` once this flag has been passed to `SpamVerdictService` # TODO: remove `unless target.allow_possible_spam?` once this flag has been passed to `SpamVerdictService`
......
...@@ -437,8 +437,8 @@ describe Issues::CreateService do ...@@ -437,8 +437,8 @@ describe Issues::CreateService do
end end
end end
it 'marks the issue as spam' do it 'does not mark the issue as spam' do
expect(issue).to be_spam expect(issue).not_to be_spam
end end
it 'marks the issue as needing reCAPTCHA' do it 'marks the issue as needing reCAPTCHA' do
...@@ -463,7 +463,7 @@ describe Issues::CreateService do ...@@ -463,7 +463,7 @@ describe Issues::CreateService do
end end
context 'when allow_possible_spam feature flag is false' do context 'when allow_possible_spam feature flag is false' do
it 'does not mark the issue as spam' do it 'marks the issue as spam' do
expect(issue).to be_spam expect(issue).to be_spam
end end
...@@ -490,6 +490,10 @@ describe Issues::CreateService do ...@@ -490,6 +490,10 @@ describe Issues::CreateService do
expect(issue).not_to be_spam expect(issue).not_to be_spam
end end
it 'does not mark the issue as needing reCAPTCHA' do
expect(issue.needs_recaptcha?).to be_falsey
end
it 'creates a valid issue' do it 'creates a valid issue' do
expect(issue).to be_valid expect(issue).to be_valid
end end
......
...@@ -121,7 +121,7 @@ describe Spam::SpamActionService do ...@@ -121,7 +121,7 @@ describe Spam::SpamActionService do
issue.description = 'SPAM!' issue.description = 'SPAM!'
end end
context 'when disallowed by the spam action service' do context 'when disallowed by the spam verdict service' do
before do before do
allow(fake_verdict_service).to receive(:execute).and_return(DISALLOW) allow(fake_verdict_service).to receive(:execute).and_return(DISALLOW)
end end
...@@ -151,7 +151,43 @@ describe Spam::SpamActionService do ...@@ -151,7 +151,43 @@ describe Spam::SpamActionService do
end end
end end
context 'when spam action service allows creation' do context 'when spam verdict service requires reCAPTCHA' do
before do
allow(fake_verdict_service).to receive(:execute).and_return(REQUIRE_RECAPTCHA)
end
context 'when allow_possible_spam feature flag is false' do
before do
stub_feature_flags(allow_possible_spam: false)
end
it_behaves_like 'only checks for spam if a request is provided'
it 'does not mark as spam' do
subject
expect(issue).not_to be_spam
end
it 'marks as needing reCAPTCHA' do
subject
expect(issue.needs_recaptcha?).to be_truthy
end
end
context 'when allow_possible_spam feature flag is true' do
it_behaves_like 'only checks for spam if a request is provided'
it 'does not mark as needing reCAPTCHA' do
subject
expect(issue.needs_recaptcha).to be_falsey
end
end
end
context 'when spam verdict service allows creation' do
before do before do
allow(fake_verdict_service).to receive(:execute).and_return(ALLOW) allow(fake_verdict_service).to receive(:execute).and_return(ALLOW)
end end
......
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