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>2020-04-21 18:21:10 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-21 18:21:10 +0300
commite33f87ac0fabaab468ce4b457996cc0f1b1bb648 (patch)
tree8bf0de72a9acac014cfdaddab7d463b208294af2 /spec/features/snippets
parent5baf990db20a75078684702782c24399ef9eb0fa (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/snippets')
-rw-r--r--spec/features/snippets/spam_snippets_spec.rb52
-rw-r--r--spec/features/snippets/user_creates_snippet_spec.rb1
-rw-r--r--spec/features/snippets/user_edits_snippet_spec.rb2
3 files changed, 50 insertions, 5 deletions
diff --git a/spec/features/snippets/spam_snippets_spec.rb b/spec/features/snippets/spam_snippets_spec.rb
index e9534dedcd3..8bba3e45824 100644
--- a/spec/features/snippets/spam_snippets_spec.rb
+++ b/spec/features/snippets/spam_snippets_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
shared_examples_for 'snippet editor' do
+ include_context 'includes Spam constants'
+
def description_field
find('.js-description-input').find('input,textarea')
end
@@ -10,6 +12,7 @@ shared_examples_for 'snippet editor' do
before do
stub_feature_flags(allow_possible_spam: false)
stub_feature_flags(snippets_vue: false)
+ stub_feature_flags(snippets_edit_vue: false)
stub_feature_flags(monaco_snippets: flag)
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
@@ -52,13 +55,30 @@ shared_examples_for 'snippet editor' do
end
end
- context 'when identified as spam' do
+ shared_examples 'does not allow creation' do
+ it 'rejects creation of the snippet' do
+ click_button('Create snippet')
+ wait_for_requests
+
+ expect(page).to have_content('discarded')
+ expect(page).not_to have_content('My Snippet Title')
+ expect(page).not_to have_css('.recaptcha')
+ end
+ end
+
+ context 'when SpamVerdictService requires recaptcha' do
before do
- WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "true", status: 200)
+ expect_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
+ expect(verdict_service).to receive(:execute).and_return(REQUIRE_RECAPTCHA)
+ end
end
context 'when allow_possible_spam feature flag is false' do
- it_behaves_like 'solve recaptcha'
+ before do
+ stub_application_setting(recaptcha_enabled: false)
+ end
+
+ it_behaves_like 'does not allow creation'
end
context 'when allow_possible_spam feature flag is true' do
@@ -66,9 +86,31 @@ shared_examples_for 'snippet editor' do
end
end
- context 'when not identified as spam' do
+ context 'when SpamVerdictService disallows' do
+ before do
+ expect_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
+ expect(verdict_service).to receive(:execute).and_return(DISALLOW)
+ end
+ end
+
+ context 'when allow_possible_spam feature flag is false' do
+ before do
+ stub_application_setting(recaptcha_enabled: false)
+ end
+
+ it_behaves_like 'does not allow creation'
+ end
+
+ context 'when allow_possible_spam feature flag is true' do
+ it_behaves_like 'does not allow creation'
+ end
+ end
+
+ context 'when SpamVerdictService allows' do
before do
- WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "false", status: 200)
+ expect_next_instance_of(Spam::SpamVerdictService) do |verdict_service|
+ expect(verdict_service).to receive(:execute).and_return(ALLOW)
+ end
end
it 'creates a snippet' do
diff --git a/spec/features/snippets/user_creates_snippet_spec.rb b/spec/features/snippets/user_creates_snippet_spec.rb
index 93da976dee0..5d3a84dd7bc 100644
--- a/spec/features/snippets/user_creates_snippet_spec.rb
+++ b/spec/features/snippets/user_creates_snippet_spec.rb
@@ -5,6 +5,7 @@ require 'spec_helper'
shared_examples_for 'snippet editor' do
before do
stub_feature_flags(snippets_vue: false)
+ stub_feature_flags(snippets_edit_vue: false)
stub_feature_flags(monaco_snippets: flag)
sign_in(user)
visit new_snippet_path
diff --git a/spec/features/snippets/user_edits_snippet_spec.rb b/spec/features/snippets/user_edits_snippet_spec.rb
index 0bbb92b1f3f..76d658a21c6 100644
--- a/spec/features/snippets/user_edits_snippet_spec.rb
+++ b/spec/features/snippets/user_edits_snippet_spec.rb
@@ -14,6 +14,7 @@ describe 'User edits snippet', :js do
before do
stub_feature_flags(snippets_vue: false)
+ stub_feature_flags(snippets_edit_vue: false)
stub_feature_flags(version_snippets: version_snippet_enabled)
sign_in(user)
@@ -91,6 +92,7 @@ describe 'User edits snippet', :js do
end
fill_in 'personal_snippet_title', with: 'New Snippet Title'
+ fill_in 'personal_snippet_file_name', with: 'new_file_name'
click_button('Save changes')
end