diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/services/spam | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) | |
download | gitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/services/spam')
-rw-r--r-- | spec/services/spam/akismet_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/spam/ham_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/spam/mark_as_spam_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/spam/spam_action_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/spam/spam_verdict_service_spec.rb | 31 |
5 files changed, 14 insertions, 25 deletions
diff --git a/spec/services/spam/akismet_service_spec.rb b/spec/services/spam/akismet_service_spec.rb index 413b43d0156..f75b0216b78 100644 --- a/spec/services/spam/akismet_service_spec.rb +++ b/spec/services/spam/akismet_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Spam::AkismetService do +RSpec.describe Spam::AkismetService do let(:fake_akismet_client) { double(:akismet_client) } let_it_be(:text) { "Would you like to buy some tinned meat product?" } diff --git a/spec/services/spam/ham_service_spec.rb b/spec/services/spam/ham_service_spec.rb index 9848f48def2..c947de6cf92 100644 --- a/spec/services/spam/ham_service_spec.rb +++ b/spec/services/spam/ham_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Spam::HamService do +RSpec.describe Spam::HamService do let_it_be(:user) { create(:user) } let!(:spam_log) { create(:spam_log, user: user, submitted_as_ham: false) } let(:fake_akismet_service) { double(:akismet_service) } diff --git a/spec/services/spam/mark_as_spam_service_spec.rb b/spec/services/spam/mark_as_spam_service_spec.rb index 9978005279a..308a66c3a48 100644 --- a/spec/services/spam/mark_as_spam_service_spec.rb +++ b/spec/services/spam/mark_as_spam_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Spam::MarkAsSpamService do +RSpec.describe Spam::MarkAsSpamService do let(:user_agent_detail) { build(:user_agent_detail) } let(:spammable) { build(:issue, user_agent_detail: user_agent_detail) } let(:fake_akismet_service) { double(:akismet_service, submit_spam: true) } diff --git a/spec/services/spam/spam_action_service_spec.rb b/spec/services/spam/spam_action_service_spec.rb index 7b6b65c82b1..abb8e49ec52 100644 --- a/spec/services/spam/spam_action_service_spec.rb +++ b/spec/services/spam/spam_action_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Spam::SpamActionService do +RSpec.describe Spam::SpamActionService do include_context 'includes Spam constants' let(:fake_ip) { '1.2.3.4' } diff --git a/spec/services/spam/spam_verdict_service_spec.rb b/spec/services/spam/spam_verdict_service_spec.rb index f6d9cd96da5..d775e1bdfb5 100644 --- a/spec/services/spam/spam_verdict_service_spec.rb +++ b/spec/services/spam/spam_verdict_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe Spam::SpamVerdictService do +RSpec.describe Spam::SpamVerdictService do include_context 'includes Spam constants' let(:fake_ip) { '1.2.3.4' } @@ -27,7 +27,7 @@ describe Spam::SpamVerdictService do before do allow(service).to receive(:akismet_verdict).and_return(nil) - allow(service).to receive(:spam_verdict_verdict).and_return(nil) + allow(service).to receive(:external_verdict).and_return(nil) end context 'if all services return nil' do @@ -62,7 +62,7 @@ describe Spam::SpamVerdictService do context 'and they are supported' do before do allow(service).to receive(:akismet_verdict).and_return(DISALLOW) - allow(service).to receive(:spam_verdict).and_return(BLOCK_USER) + allow(service).to receive(:external_verdict).and_return(BLOCK_USER) end it 'renders the more restrictive verdict' do @@ -73,18 +73,7 @@ describe Spam::SpamVerdictService do context 'and one is supported' do before do allow(service).to receive(:akismet_verdict).and_return('nonsense') - allow(service).to receive(:spam_verdict).and_return(BLOCK_USER) - end - - it 'renders the more restrictive verdict' do - expect(subject).to eq BLOCK_USER - end - end - - context 'and one is supported' do - before do - allow(service).to receive(:akismet_verdict).and_return('nonsense') - allow(service).to receive(:spam_verdict).and_return(BLOCK_USER) + allow(service).to receive(:external_verdict).and_return(BLOCK_USER) end it 'renders the more restrictive verdict' do @@ -95,7 +84,7 @@ describe Spam::SpamVerdictService do context 'and none are supported' do before do allow(service).to receive(:akismet_verdict).and_return('nonsense') - allow(service).to receive(:spam_verdict).and_return('rubbish') + allow(service).to receive(:external_verdict).and_return('rubbish') end it 'renders the more restrictive verdict' do @@ -160,8 +149,8 @@ describe Spam::SpamVerdictService do end end - describe '#spam_verdict' do - subject { service.send(:spam_verdict) } + describe '#external_verdict' do + subject { service.send(:external_verdict) } context 'if a Spam Check endpoint enabled and set to a URL' do let(:spam_check_body) { {} } @@ -192,8 +181,8 @@ describe Spam::SpamVerdictService do context 'the verdict is an unexpected string' do let(:verdict) { 'this is fine' } - it 'returns nil' do - expect(subject).to be_nil + it 'returns the string' do + expect(subject).to eq verdict end end @@ -209,7 +198,7 @@ describe Spam::SpamVerdictService do let(:verdict) { '' } it 'returns nil' do - expect(subject).to be_nil + expect(subject).to eq verdict end end |