Commit fa030cbc authored by Maxim Rydkin's avatar Maxim Rydkin

replace `is_spam?` with `spam?`

parent 1c0def2a
......@@ -7,7 +7,7 @@ class AkismetService
@options = options
end
def is_spam?
def spam?
return false unless akismet_enabled?
params = {
......
......@@ -45,7 +45,7 @@ class SpamService
def check(api)
return false unless request && check_for_spam?
return false unless akismet.is_spam?
return false unless akismet.spam?
create_spam_log(api)
true
......
......@@ -268,7 +268,7 @@ describe Projects::IssuesController do
context 'when an issue is not identified as spam' do
before do
allow_any_instance_of(described_class).to receive(:verify_recaptcha).and_return(false)
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(false)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(false)
end
it 'normally updates the issue' do
......@@ -278,7 +278,7 @@ describe Projects::IssuesController do
context 'when an issue is identified as spam' do
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
context 'when captcha is not verified' do
......@@ -672,7 +672,7 @@ describe Projects::IssuesController do
context 'when an issue is not identified as spam' do
before do
allow_any_instance_of(described_class).to receive(:verify_recaptcha).and_return(false)
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(false)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(false)
end
it 'does not create an issue' do
......@@ -682,7 +682,7 @@ describe Projects::IssuesController do
context 'when an issue is identified as spam' do
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
context 'when captcha is not verified' do
......
......@@ -98,7 +98,7 @@ describe Projects::SnippetsController do
context 'when the snippet is spam' do
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
context 'when the snippet is private' do
......@@ -176,7 +176,7 @@ describe Projects::SnippetsController do
context 'when the snippet is spam' do
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
context 'when the snippet is private' do
......
......@@ -217,7 +217,7 @@ describe SnippetsController do
context 'when the snippet is spam' do
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
context 'when the snippet is private' do
......@@ -289,7 +289,7 @@ describe SnippetsController do
context 'when the snippet is spam' do
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
context 'when the snippet is private' do
......
......@@ -984,7 +984,7 @@ describe API::Issues, :mailer do
describe 'POST /projects/:id/issues with spam filtering' do
before do
allow_any_instance_of(SpamService).to receive(:check_for_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive_messages(is_spam?: true)
allow_any_instance_of(AkismetService).to receive_messages(spam?: true)
end
let(:params) do
......@@ -1114,7 +1114,7 @@ describe API::Issues, :mailer do
it "does not create a new project issue" do
allow_any_instance_of(SpamService).to receive_messages(check_for_spam?: true)
allow_any_instance_of(AkismetService).to receive_messages(is_spam?: true)
allow_any_instance_of(AkismetService).to receive_messages(spam?: true)
put api("/projects/#{project.id}/issues/#{issue.iid}", user), params
......
......@@ -117,7 +117,7 @@ describe API::ProjectSnippets do
end
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
context 'when the snippet is private' do
......@@ -179,7 +179,7 @@ describe API::ProjectSnippets do
end
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
context 'when the snippet is private' do
......
......@@ -137,7 +137,7 @@ describe API::Snippets do
end
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
context 'when the snippet is private' do
......@@ -209,7 +209,7 @@ describe API::Snippets do
end
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
context 'when the snippet is private' do
......
......@@ -884,7 +884,7 @@ describe API::V3::Issues, :mailer do
describe 'POST /projects/:id/issues with spam filtering' do
before do
allow_any_instance_of(SpamService).to receive(:check_for_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive_messages(is_spam?: true)
allow_any_instance_of(AkismetService).to receive_messages(spam?: true)
end
let(:params) do
......@@ -1016,7 +1016,7 @@ describe API::V3::Issues, :mailer do
it "does not create a new project issue" do
allow_any_instance_of(SpamService).to receive_messages(check_for_spam?: true)
allow_any_instance_of(AkismetService).to receive_messages(is_spam?: true)
allow_any_instance_of(AkismetService).to receive_messages(spam?: true)
put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), params
......
......@@ -80,7 +80,7 @@ describe API::ProjectSnippets do
end
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
context 'when the snippet is private' do
......@@ -140,7 +140,7 @@ describe API::ProjectSnippets do
end
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
context 'when the snippet is private' do
......
......@@ -107,7 +107,7 @@ describe API::V3::Snippets do
end
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
context 'when the snippet is private' do
......
......@@ -370,7 +370,7 @@ describe Issues::CreateService do
context 'when recaptcha was not verified' do
context 'when akismet detects spam' do
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
it 'marks an issue as a spam ' do
......@@ -392,7 +392,7 @@ describe Issues::CreateService do
context 'when akismet does not detect spam' do
before do
allow_any_instance_of(AkismetService).to receive(:is_spam?).and_return(false)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(false)
end
it 'does not mark an issue as a spam ' do
......
......@@ -23,7 +23,7 @@ describe SpamService do
before do
issue.closed_at = Time.zone.now
allow(AkismetService).to receive(:new).and_return(double(is_spam?: true))
allow(AkismetService).to receive(:new).and_return(double(spam?: true))
end
it 'returns false' do
......@@ -43,7 +43,7 @@ describe SpamService do
context 'when indicated as spam by akismet' do
before do
allow(AkismetService).to receive(:new).and_return(double(is_spam?: true))
allow(AkismetService).to receive(:new).and_return(double(spam?: true))
end
it 'doesnt check as spam when request is missing' do
......@@ -71,7 +71,7 @@ describe SpamService do
context 'when not indicated as spam by akismet' do
before do
allow(AkismetService).to receive(:new).and_return(double(is_spam?: false))
allow(AkismetService).to receive(:new).and_return(double(spam?: false))
end
it 'returns false' do
......
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