Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-25 06:06:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-25 06:06:21 +0300
commit7bb7a8d529fd1155a35a2e9e9cdddd7953f3776d (patch)
treee0cedf3ea8732ab14cd918242279619c3c7d7072 /spec/services/issues
parent504ab1e32cbd3a529fe61f6c9a30823febce796c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/issues')
-rw-r--r--spec/services/issues/create_service_spec.rb62
1 files changed, 49 insertions, 13 deletions
diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb
index b7bedc2f97e..5dc6b6176ee 100644
--- a/spec/services/issues/create_service_spec.rb
+++ b/spec/services/issues/create_service_spec.rb
@@ -344,7 +344,7 @@ describe Issues::CreateService do
end
before do
- allow_any_instance_of(SpamService).to receive(:check_for_spam?).and_return(true)
+ stub_feature_flags(allow_possible_spam: false)
end
context 'when recaptcha was verified' do
@@ -384,31 +384,67 @@ describe Issues::CreateService do
end
context 'when recaptcha was not verified' do
+ before do
+ expect_next_instance_of(SpamService) do |spam_service|
+ expect(spam_service).to receive_messages(check_for_spam?: true)
+ end
+ end
+
context 'when akismet detects spam' do
before do
- allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
+ expect_next_instance_of(AkismetService) do |akismet_service|
+ expect(akismet_service).to receive_messages(spam?: true)
+ end
end
- it 'marks an issue as a spam ' do
- expect(issue).to be_spam
- end
+ context 'when issuables_recaptcha_enabled feature flag is true' do
+ it 'marks an issue as a spam ' do
+ expect(issue).to be_spam
+ end
- it 'an issue is not valid ' do
- expect(issue.valid?).to be_falsey
- end
+ it 'invalidates the issue' do
+ expect(issue).to be_invalid
+ end
+
+ it 'creates a new spam_log' do
+ expect { issue }
+ .to log_spam(title: issue.title, description: issue.description, user_id: user.id, noteable_type: 'Issue')
+ end
- it 'creates a new spam_log' do
- expect {issue}.to change {SpamLog.count}.from(0).to(1)
+ it 'assigns a spam_log to an issue' do
+ expect(issue.spam_log).to eq(SpamLog.last)
+ end
end
- it 'assigns a spam_log to an issue' do
- expect(issue.spam_log).to eq(SpamLog.last)
+ context 'when issuable_recaptcha_enabled feature flag is false' do
+ before do
+ stub_feature_flags(allow_possible_spam: true)
+ end
+
+ it 'does not mark an issue as a spam ' do
+ expect(issue).not_to be_spam
+ end
+
+ it 'accepts the ​issue as valid' do
+ expect(issue).to be_valid
+ end
+
+ it 'creates a new spam_log' do
+ expect { issue }
+ .to log_spam(title: issue.title, description: issue.description, user_id: user.id, noteable_type: 'Issue')
+ end
+
+ it 'assigns a spam_log to an issue' do
+ expect(issue.spam_log).to eq(SpamLog.last)
+ end
end
end
context 'when akismet does not detect spam' do
before do
- allow_any_instance_of(AkismetService).to receive(:spam?).and_return(false)
+ expect_next_instance_of(AkismetService) do |akismet_service|
+ expect(akismet_service).to receive_messages(spam?: false)
+ end
end
it 'does not mark an issue as a spam ' do