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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-12 12:09:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-12 12:09:11 +0300
commit0388886f9439fa93efea29a159522aec5643f7c8 (patch)
tree9a4b2305088e62a9745ce598b45aa34e39e59642 /spec/services/spam
parent8c9dc985b90c353b33cb829caf51f8320171bc15 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/spam')
-rw-r--r--spec/services/spam/ham_service_spec.rb14
-rw-r--r--spec/services/spam/mark_as_spam_service_spec.rb14
-rw-r--r--spec/services/spam/spam_check_service_spec.rb12
3 files changed, 20 insertions, 20 deletions
diff --git a/spec/services/spam/ham_service_spec.rb b/spec/services/spam/ham_service_spec.rb
index 9848f48def2..a4583108dba 100644
--- a/spec/services/spam/ham_service_spec.rb
+++ b/spec/services/spam/ham_service_spec.rb
@@ -4,10 +4,10 @@ require 'spec_helper'
describe Spam::HamService do
let_it_be(:user) { create(:user) }
- let!(:spam_log) { create(:spam_log, user: user, submitted_as_ham: false) }
+ let!(:target) { create(:spam_log, user: user, submitted_as_ham: false) }
let(:fake_akismet_service) { double(:akismet_service) }
- subject { described_class.new(spam_log) }
+ subject { described_class.new(target) }
before do
allow(Spam::AkismetService).to receive(:new).and_return fake_akismet_service
@@ -24,23 +24,23 @@ describe Spam::HamService do
end
it 'does not update the record' do
- expect { subject.execute }.not_to change { spam_log.submitted_as_ham }
+ expect { subject.execute }.not_to change { target.submitted_as_ham }
end
context 'if spam log record has already been marked as spam' do
before do
- spam_log.update_attribute(:submitted_as_ham, true)
+ target.update_attribute(:submitted_as_ham, true)
end
it 'does not update the record' do
- expect { subject.execute }.not_to change { spam_log.submitted_as_ham }
+ expect { subject.execute }.not_to change { target.submitted_as_ham }
end
end
end
context 'Akismet ham submission is successful' do
before do
- spam_log.update_attribute(:submitted_as_ham, false)
+ target.update_attribute(:submitted_as_ham, false)
allow(fake_akismet_service).to receive(:submit_ham).and_return true
end
@@ -49,7 +49,7 @@ describe Spam::HamService do
end
it 'updates the record' do
- expect { subject.execute }.to change { spam_log.submitted_as_ham }.from(false).to(true)
+ expect { subject.execute }.to change { target.submitted_as_ham }.from(false).to(true)
end
end
end
diff --git a/spec/services/spam/mark_as_spam_service_spec.rb b/spec/services/spam/mark_as_spam_service_spec.rb
index cba9d6a39cb..3824a8244bb 100644
--- a/spec/services/spam/mark_as_spam_service_spec.rb
+++ b/spec/services/spam/mark_as_spam_service_spec.rb
@@ -4,19 +4,19 @@ require 'spec_helper'
describe Spam::MarkAsSpamService do
let(:user_agent_detail) { build(:user_agent_detail) }
- let(:spammable) { build(:issue, user_agent_detail: user_agent_detail) }
+ let(:target) { build(:issue, user_agent_detail: user_agent_detail) }
let(:fake_akismet_service) { double(:akismet_service, submit_spam: true) }
- subject { described_class.new(spammable: spammable) }
+ subject { described_class.new(target: target) }
describe '#execute' do
before do
allow(subject).to receive(:akismet).and_return(fake_akismet_service)
end
- context 'when the spammable object is not submittable' do
+ context 'when the target object is not submittable' do
before do
- allow(spammable).to receive(:submittable_as_spam?).and_return false
+ allow(target).to receive(:submittable_as_spam?).and_return false
end
it 'does not submit as spam' do
@@ -26,7 +26,7 @@ describe Spam::MarkAsSpamService do
context 'spam is submitted successfully' do
before do
- allow(spammable).to receive(:submittable_as_spam?).and_return true
+ allow(target).to receive(:submittable_as_spam?).and_return true
allow(fake_akismet_service).to receive(:submit_spam).and_return true
end
@@ -34,14 +34,14 @@ describe Spam::MarkAsSpamService do
expect(subject.execute).to be_truthy
end
- it "updates the spammable object's user agent detail as being submitted as spam" do
+ it "updates the target object's user agent detail as being submitted as spam" do
expect(user_agent_detail).to receive(:update_attribute)
subject.execute
end
context 'when Akismet does not consider it spam' do
- it 'does not update the spammable object as spam' do
+ it 'does not update the target object as spam' do
allow(fake_akismet_service).to receive(:submit_spam).and_return false
expect(subject.execute).to be_falsey
diff --git a/spec/services/spam/spam_check_service_spec.rb b/spec/services/spam/spam_check_service_spec.rb
index 732b64b52a0..376afc78b5f 100644
--- a/spec/services/spam/spam_check_service_spec.rb
+++ b/spec/services/spam/spam_check_service_spec.rb
@@ -22,12 +22,12 @@ describe Spam::SpamCheckService do
end
describe '#initialize' do
- subject { described_class.new(spammable: issue, request: request) }
+ subject { described_class.new(target: issue, request: request) }
context 'when the request is nil' do
let(:request) { nil }
- it 'assembles the options with information from the spammable' do
+ it 'assembles the options with information from the target' do
aggregate_failures do
expect(subject.options[:ip_address]).to eq(issue.ip_address)
expect(subject.options[:user_agent]).to eq(issue.user_agent)
@@ -39,7 +39,7 @@ describe Spam::SpamCheckService do
context 'when the request is present' do
let(:request) { double(:request, env: env) }
- it 'assembles the options with information from the spammable' do
+ it 'assembles the options with information from the target' do
aggregate_failures do
expect(subject.options[:ip_address]).to eq(fake_ip)
expect(subject.options[:user_agent]).to eq(fake_user_agent)
@@ -55,7 +55,7 @@ describe Spam::SpamCheckService do
let_it_be(:existing_spam_log) { create(:spam_log, user: user, recaptcha_verified: false) }
subject do
- described_service = described_class.new(spammable: issue, request: request)
+ described_service = described_class.new(target: issue, request: request)
described_service.execute(user_id: user.id, api: nil, recaptcha_verified: recaptcha_verified, spam_log_id: existing_spam_log.id)
end
@@ -81,7 +81,7 @@ describe Spam::SpamCheckService do
context 'when recaptcha was not verified' do
let(:recaptcha_verified) { false }
- context 'when spammable attributes have not changed' do
+ context 'when target attributes have not changed' do
before do
issue.closed_at = Time.zone.now
@@ -98,7 +98,7 @@ describe Spam::SpamCheckService do
end
end
- context 'when spammable attributes have changed' do
+ context 'when target attributes have changed' do
before do
issue.description = 'SPAM!'
end