Commit b921bd2b authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'cablett-spam-test-refactor-2' into 'master'

Small spam tidbits

See merge request gitlab-org/gitlab!28911
parents 8fc3e503 5968a3a5
......@@ -725,7 +725,7 @@ describe Projects::IssuesController do
stub_feature_flags(allow_possible_spam: false)
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 }
end
......@@ -981,7 +981,7 @@ describe Projects::IssuesController do
stub_feature_flags(allow_possible_spam: false)
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)
end
......
......@@ -23,7 +23,7 @@ describe 'New issue', :js do
sign_in(user)
end
context 'when identified as a spam' do
context 'when identified as spam' do
before do
WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "true", status: 200)
......@@ -74,7 +74,7 @@ describe 'New issue', :js do
end
end
context 'when not identified as a spam' do
context 'when not identified as spam' do
before do
WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: 'false', status: 200)
......
......@@ -52,7 +52,7 @@ shared_examples_for 'snippet editor' do
end
end
context 'when identified as a spam' do
context 'when identified as spam' do
before do
WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "true", status: 200)
end
......@@ -66,7 +66,7 @@ shared_examples_for 'snippet editor' do
end
end
context 'when not identified as a spam' do
context 'when not identified as spam' do
before do
WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "false", status: 200)
end
......
......@@ -383,20 +383,21 @@ describe Issues::CreateService do
context 'when recaptcha was verified' do
let(:log_user) { user }
let(:spam_logs) { create_list(:spam_log, 2, user: log_user, title: 'Awesome issue') }
let(:target_spam_log) { spam_logs.last }
before do
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)
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
end
it 'an issue is valid ' do
expect(issue.valid?).to be_truthy
it 'issue is valid ' do
expect(issue).to be_valid
end
it 'does not assign a spam_log to an issue' do
......@@ -431,7 +432,7 @@ describe Issues::CreateService do
end
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
end
......@@ -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')
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)
end
end
......@@ -454,7 +455,7 @@ describe Issues::CreateService do
stub_feature_flags(allow_possible_spam: true)
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
end
......@@ -480,7 +481,7 @@ describe Issues::CreateService do
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
end
......
......@@ -76,7 +76,7 @@ describe Snippets::CreateService do
shared_examples 'spam check is performed' 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
end
......
......@@ -91,9 +91,7 @@ describe Spam::SpamCheckService do
end
it 'updates spam log' do
subject
expect(existing_spam_log.reload.recaptcha_verified).to be_truthy
expect { subject }.to change { existing_spam_log.reload.recaptcha_verified }.from(false).to(true)
end
end
......@@ -137,7 +135,7 @@ describe Spam::SpamCheckService do
it 'marks as spam' do
subject
expect(issue.reload.spam).to be_truthy
expect(issue).to be_spam
end
end
......@@ -147,7 +145,7 @@ describe Spam::SpamCheckService do
it 'does not mark as spam' do
subject
expect(issue.spam).to be_falsey
expect(issue).not_to be_spam
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