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:
authorStan Hu <stanhu@gmail.com>2018-08-24 01:21:06 +0300
committerStan Hu <stanhu@gmail.com>2018-08-24 20:29:14 +0300
commitf2005125dfe7810de910b61dee8d7a9203a6ca6e (patch)
tree292dbe52167f294d75e7637e60c521c02a0cdb4d /spec/helpers/import_helper_spec.rb
parent842377ab3c5b80a3758ad8c36dc3358bd265bc10 (diff)
Use slugs for default project path and sanitize names before import
Users importing from Bitbucket Cloud, Bitbucket Server, or GitHub often complained about getting failed imports due to 422 errors. This change ensures that project names are imported with names that are guaranteed to pass the regular expression validation. Part of #50021
Diffstat (limited to 'spec/helpers/import_helper_spec.rb')
-rw-r--r--spec/helpers/import_helper_spec.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/helpers/import_helper_spec.rb b/spec/helpers/import_helper_spec.rb
index 033155617c6..cb0ea4e26ba 100644
--- a/spec/helpers/import_helper_spec.rb
+++ b/spec/helpers/import_helper_spec.rb
@@ -1,6 +1,16 @@
require 'rails_helper'
describe ImportHelper do
+ describe '#sanitize_project_name' do
+ it 'removes whitespace' do
+ expect(helper.sanitize_project_name('my test repo')).to eq('my-test-repo')
+ end
+
+ it 'removes disallowed characters' do
+ expect(helper.sanitize_project_name('Test&me$over*h_ere')).to eq('Test-me-over-h_ere')
+ end
+ end
+
describe '#import_project_target' do
let(:user) { create(:user) }