From b69f406585ff64b1c5140ebba775cc754fabb358 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Sat, 15 Feb 2020 00:08:48 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- spec/services/spam/ham_service_spec.rb | 14 +++++++------- spec/services/spam/mark_as_spam_service_spec.rb | 14 +++++++------- spec/services/spam/spam_check_service_spec.rb | 12 ++++++------ 3 files changed, 20 insertions(+), 20 deletions(-) (limited to 'spec/services/spam') diff --git a/spec/services/spam/ham_service_spec.rb b/spec/services/spam/ham_service_spec.rb index a4583108dba..9848f48def2 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!(:target) { create(:spam_log, user: user, submitted_as_ham: false) } + let!(:spam_log) { create(:spam_log, user: user, submitted_as_ham: false) } let(:fake_akismet_service) { double(:akismet_service) } - subject { described_class.new(target) } + subject { described_class.new(spam_log) } 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 { target.submitted_as_ham } + expect { subject.execute }.not_to change { spam_log.submitted_as_ham } end context 'if spam log record has already been marked as spam' do before do - target.update_attribute(:submitted_as_ham, true) + spam_log.update_attribute(:submitted_as_ham, true) end it 'does not update the record' do - expect { subject.execute }.not_to change { target.submitted_as_ham } + expect { subject.execute }.not_to change { spam_log.submitted_as_ham } end end end context 'Akismet ham submission is successful' do before do - target.update_attribute(:submitted_as_ham, false) + spam_log.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 { target.submitted_as_ham }.from(false).to(true) + expect { subject.execute }.to change { spam_log.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 3824a8244bb..cba9d6a39cb 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(:target) { build(:issue, user_agent_detail: user_agent_detail) } + let(:spammable) { build(:issue, user_agent_detail: user_agent_detail) } let(:fake_akismet_service) { double(:akismet_service, submit_spam: true) } - subject { described_class.new(target: target) } + subject { described_class.new(spammable: spammable) } describe '#execute' do before do allow(subject).to receive(:akismet).and_return(fake_akismet_service) end - context 'when the target object is not submittable' do + context 'when the spammable object is not submittable' do before do - allow(target).to receive(:submittable_as_spam?).and_return false + allow(spammable).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(target).to receive(:submittable_as_spam?).and_return true + allow(spammable).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 target object's user agent detail as being submitted as spam" do + it "updates the spammable 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 target object as spam' do + it 'does not update the spammable 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 376afc78b5f..732b64b52a0 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(target: issue, request: request) } + subject { described_class.new(spammable: issue, request: request) } context 'when the request is nil' do let(:request) { nil } - it 'assembles the options with information from the target' do + it 'assembles the options with information from the spammable' 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 target' do + it 'assembles the options with information from the spammable' 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(target: issue, request: request) + described_service = described_class.new(spammable: 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 target attributes have not changed' do + context 'when spammable 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 target attributes have changed' do + context 'when spammable attributes have changed' do before do issue.description = 'SPAM!' end -- cgit v1.2.3