Commit 5968a3a5 authored by charlieablett's avatar charlieablett

Small spam tidbits

- Fix some typos
- One-line fixes to tighten up tests
parent 852bf484
...@@ -725,7 +725,7 @@ describe Projects::IssuesController do ...@@ -725,7 +725,7 @@ describe Projects::IssuesController do
stub_feature_flags(allow_possible_spam: false) stub_feature_flags(allow_possible_spam: false)
end end
it 'rejects an issue recognized as a spam' do it 'rejects an issue recognized as spam' do
expect { update_issue }.not_to change { issue.reload.title } expect { update_issue }.not_to change { issue.reload.title }
end end
...@@ -981,7 +981,7 @@ describe Projects::IssuesController do ...@@ -981,7 +981,7 @@ describe Projects::IssuesController do
stub_feature_flags(allow_possible_spam: false) stub_feature_flags(allow_possible_spam: false)
end end
it 'rejects an issue recognized as a spam' do it 'rejects an issue recognized as spam' do
expect { post_spam_issue }.not_to change(Issue, :count) expect { post_spam_issue }.not_to change(Issue, :count)
end end
......
...@@ -23,7 +23,7 @@ describe 'New issue', :js do ...@@ -23,7 +23,7 @@ describe 'New issue', :js do
sign_in(user) sign_in(user)
end end
context 'when identified as a spam' do context 'when identified as spam' do
before do before do
WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "true", status: 200) WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "true", status: 200)
...@@ -74,7 +74,7 @@ describe 'New issue', :js do ...@@ -74,7 +74,7 @@ describe 'New issue', :js do
end end
end end
context 'when not identified as a spam' do context 'when not identified as spam' do
before do before do
WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: 'false', status: 200) WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: 'false', status: 200)
......
...@@ -52,7 +52,7 @@ shared_examples_for 'snippet editor' do ...@@ -52,7 +52,7 @@ shared_examples_for 'snippet editor' do
end end
end end
context 'when identified as a spam' do context 'when identified as spam' do
before do before do
WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "true", status: 200) WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "true", status: 200)
end end
...@@ -66,7 +66,7 @@ shared_examples_for 'snippet editor' do ...@@ -66,7 +66,7 @@ shared_examples_for 'snippet editor' do
end end
end end
context 'when not identified as a spam' do context 'when not identified as spam' do
before do before do
WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "false", status: 200) WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "false", status: 200)
end end
......
...@@ -383,20 +383,21 @@ describe Issues::CreateService do ...@@ -383,20 +383,21 @@ describe Issues::CreateService do
context 'when recaptcha was verified' do context 'when recaptcha was verified' do
let(:log_user) { user } let(:log_user) { user }
let(:spam_logs) { create_list(:spam_log, 2, user: log_user, title: 'Awesome issue') } let(:spam_logs) { create_list(:spam_log, 2, user: log_user, title: 'Awesome issue') }
let(:target_spam_log) { spam_logs.last }
before do before do
opts[:recaptcha_verified] = true opts[:recaptcha_verified] = true
opts[:spam_log_id] = spam_logs.last.id opts[:spam_log_id] = target_spam_log.id
expect(Spam::AkismetService).not_to receive(:new) expect(Spam::AkismetService).not_to receive(:new)
end end
it 'does no mark an issue as a spam ' do it 'does not mark an issue as spam' do
expect(issue).not_to be_spam expect(issue).not_to be_spam
end end
it 'an issue is valid ' do it 'issue is valid ' do
expect(issue.valid?).to be_truthy expect(issue).to be_valid
end end
it 'does not assign a spam_log to an issue' do it 'does not assign a spam_log to an issue' do
...@@ -431,7 +432,7 @@ describe Issues::CreateService do ...@@ -431,7 +432,7 @@ describe Issues::CreateService do
end end
context 'when issuables_recaptcha_enabled feature flag is true' do context 'when issuables_recaptcha_enabled feature flag is true' do
it 'marks an issue as a spam ' do it 'marks an issue as spam' do
expect(issue).to be_spam expect(issue).to be_spam
end end
...@@ -444,7 +445,7 @@ describe Issues::CreateService do ...@@ -444,7 +445,7 @@ describe Issues::CreateService do
.to have_spam_log(title: issue.title, description: issue.description, user_id: user.id, noteable_type: 'Issue') .to have_spam_log(title: issue.title, description: issue.description, user_id: user.id, noteable_type: 'Issue')
end end
it 'assigns a spam_log to an issue' do it 'assigns a spam_log to the issue' do
expect(issue.spam_log).to eq(SpamLog.last) expect(issue.spam_log).to eq(SpamLog.last)
end end
end end
...@@ -454,7 +455,7 @@ describe Issues::CreateService do ...@@ -454,7 +455,7 @@ describe Issues::CreateService do
stub_feature_flags(allow_possible_spam: true) stub_feature_flags(allow_possible_spam: true)
end end
it 'does not mark an issue as a spam ' do it 'does not mark an issue as spam' do
expect(issue).not_to be_spam expect(issue).not_to be_spam
end end
...@@ -480,7 +481,7 @@ describe Issues::CreateService do ...@@ -480,7 +481,7 @@ describe Issues::CreateService do
end end
end end
it 'does not mark an issue as a spam ' do it 'does not mark an issue as spam' do
expect(issue).not_to be_spam expect(issue).not_to be_spam
end end
......
...@@ -76,7 +76,7 @@ describe Snippets::CreateService do ...@@ -76,7 +76,7 @@ describe Snippets::CreateService do
shared_examples 'spam check is performed' do shared_examples 'spam check is performed' do
shared_examples 'marked as spam' do shared_examples 'marked as spam' do
it 'marks a snippet as spam ' do it 'marks a snippet as spam' do
expect(snippet).to be_spam expect(snippet).to be_spam
end end
......
...@@ -91,9 +91,7 @@ describe Spam::SpamCheckService do ...@@ -91,9 +91,7 @@ describe Spam::SpamCheckService do
end end
it 'updates spam log' do it 'updates spam log' do
subject expect { subject }.to change { existing_spam_log.reload.recaptcha_verified }.from(false).to(true)
expect(existing_spam_log.reload.recaptcha_verified).to be_truthy
end end
end end
...@@ -137,7 +135,7 @@ describe Spam::SpamCheckService do ...@@ -137,7 +135,7 @@ describe Spam::SpamCheckService do
it 'marks as spam' do it 'marks as spam' do
subject subject
expect(issue.reload.spam).to be_truthy expect(issue).to be_spam
end end
end end
...@@ -147,7 +145,7 @@ describe Spam::SpamCheckService do ...@@ -147,7 +145,7 @@ describe Spam::SpamCheckService do
it 'does not mark as spam' do it 'does not mark as spam' do
subject subject
expect(issue.spam).to be_falsey expect(issue).not_to be_spam
end end
end end
end end
......
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