Commit fa030cbc authored by Maxim Rydkin's avatar Maxim Rydkin

replace `is_spam?` with `spam?`

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