diff options
author | Stan Hu <stanhu@gmail.com> | 2018-12-06 03:43:29 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2019-01-29 00:06:27 +0300 |
commit | eafccaad7346d6e1f8d13024bb5295bc683ab046 (patch) | |
tree | 433d6ed6404f8c2edd77a03a6254c2884300974f /spec/controllers/import | |
parent | c2b3f64cb44114e69ddeeb453412ad4dd762baf9 (diff) |
Fix Bitbucket Server import not allowing personal projects
Bitbucket Server places personal projects in a namespace called
`~username`. This change allows those projects and also strips
them from the GitLab namespace.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/53419
Diffstat (limited to 'spec/controllers/import')
-rw-r--r-- | spec/controllers/import/bitbucket_server_controller_spec.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/spec/controllers/import/bitbucket_server_controller_spec.rb b/spec/controllers/import/bitbucket_server_controller_spec.rb index bb282db5a41..a125e6ed16d 100644 --- a/spec/controllers/import/bitbucket_server_controller_spec.rb +++ b/spec/controllers/import/bitbucket_server_controller_spec.rb @@ -28,9 +28,11 @@ describe Import::BitbucketServerController do end describe 'POST create' do + let(:project_name) { "my-project_123" } + before do allow(controller).to receive(:bitbucket_client).and_return(client) - repo = double(name: 'my-project') + repo = double(name: project_name) allow(client).to receive(:repo).with(project_key, repo_slug).and_return(repo) assign_session_tokens end @@ -39,7 +41,7 @@ describe Import::BitbucketServerController do it 'returns the new project' do allow(Gitlab::BitbucketServerImport::ProjectCreator) - .to receive(:new).with(project_key, repo_slug, anything, 'my-project', user.namespace, user, anything) + .to receive(:new).with(project_key, repo_slug, anything, project_name, user.namespace, user, anything) .and_return(double(execute: project)) post :create, params: { project: project_key, repository: repo_slug }, format: :json @@ -47,6 +49,20 @@ describe Import::BitbucketServerController do expect(response).to have_gitlab_http_status(200) end + context 'with project key with tildes' do + let(:project_key) { '~someuser_123' } + + it 'successfully creates a project' do + allow(Gitlab::BitbucketServerImport::ProjectCreator) + .to receive(:new).with(project_key, repo_slug, anything, project_name, user.namespace, user, anything) + .and_return(double(execute: project)) + + post :create, params: { project: project_key, repository: repo_slug, format: :json } + + expect(response).to have_gitlab_http_status(200) + end + end + it 'returns an error when an invalid project key is used' do post :create, params: { project: 'some&project' } @@ -69,7 +85,7 @@ describe Import::BitbucketServerController do it 'returns an error when the project cannot be saved' do allow(Gitlab::BitbucketServerImport::ProjectCreator) - .to receive(:new).with(project_key, repo_slug, anything, 'my-project', user.namespace, user, anything) + .to receive(:new).with(project_key, repo_slug, anything, project_name, user.namespace, user, anything) .and_return(double(execute: build(:project))) post :create, params: { project: project_key, repository: repo_slug }, format: :json |