Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/spam/spam_verdict_service_spec.rb')
-rw-r--r--spec/services/spam/spam_verdict_service_spec.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/services/spam/spam_verdict_service_spec.rb b/spec/services/spam/spam_verdict_service_spec.rb
index 99047f3233b..082b8f909f9 100644
--- a/spec/services/spam/spam_verdict_service_spec.rb
+++ b/spec/services/spam/spam_verdict_service_spec.rb
@@ -27,6 +27,10 @@ RSpec.describe Spam::SpamVerdictService do
extra_attributes
end
+ before do
+ stub_feature_flags(allow_possible_spam: false)
+ end
+
describe '#execute' do
subject { service.execute }
@@ -114,6 +118,32 @@ RSpec.describe Spam::SpamVerdictService do
end
end
+ context 'if allow_possible_spam flag is true' do
+ before do
+ stub_feature_flags(allow_possible_spam: true)
+ end
+
+ context 'and a service returns a verdict that should be overridden' do
+ before do
+ allow(service).to receive(:spamcheck_verdict).and_return([BLOCK_USER, attribs])
+ end
+
+ it 'overrides and renders the override verdict' do
+ expect(subject).to eq OVERRIDE_VIA_ALLOW_POSSIBLE_SPAM
+ end
+ end
+
+ context 'and a service returns a verdict that does not need to be overridden' do
+ before do
+ allow(service).to receive(:spamcheck_verdict).and_return([ALLOW, attribs])
+ end
+
+ it 'does not override and renders the original verdict' do
+ expect(subject).to eq ALLOW
+ end
+ end
+ end
+
context 'records metrics' do
let(:histogram) { instance_double(Prometheus::Client::Histogram) }