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:
Diffstat (limited to 'spec/features/projects/new_project_spec.rb')
-rw-r--r--spec/features/projects/new_project_spec.rb91
1 files changed, 90 insertions, 1 deletions
diff --git a/spec/features/projects/new_project_spec.rb b/spec/features/projects/new_project_spec.rb
index f1786c1be40..b3fbf5d356e 100644
--- a/spec/features/projects/new_project_spec.rb
+++ b/spec/features/projects/new_project_spec.rb
@@ -306,10 +306,24 @@ RSpec.describe 'New project', :js do
expect(page).to have_text('There is not a valid Git repository at this URL')
end
+ it 'reports error if repo URL is not a valid Git repository and submit button is clicked immediately' do
+ stub_request(:get, "http://foo/bar/info/refs?service=git-upload-pack").to_return(status: 200, body: "not-a-git-repo")
+
+ fill_in 'project_import_url', with: 'http://foo/bar'
+ click_on 'Create project'
+
+ wait_for_requests
+
+ expect(page).to have_text('There is not a valid Git repository at this URL')
+ end
+
it 'keeps "Import project" tab open after form validation error' do
collision_project = create(:project, name: 'test-name-collision', namespace: user.namespace)
+ stub_request(:get, "http://foo/bar/info/refs?service=git-upload-pack").to_return({ status: 200,
+ body: '001e# service=git-upload-pack',
+ headers: { 'Content-Type': 'application/x-git-upload-pack-advertisement' } })
- fill_in 'project_import_url', with: collision_project.http_url_to_repo
+ fill_in 'project_import_url', with: 'http://foo/bar'
fill_in 'project_name', with: collision_project.name
click_on 'Create project'
@@ -319,6 +333,38 @@ RSpec.describe 'New project', :js do
end
end
+ context 'when import is initiated from project page' do
+ before do
+ project_without_repo = create(:project, name: 'project-without-repo', namespace: user.namespace)
+ visit project_path(project_without_repo)
+ click_on 'Import repository'
+ end
+
+ it 'reports error when invalid url is provided' do
+ stub_request(:get, "http://foo/bar/info/refs?service=git-upload-pack").to_return(status: 200, body: "not-a-git-repo")
+
+ fill_in 'project_import_url', with: 'http://foo/bar'
+
+ click_on 'Start import'
+ wait_for_requests
+
+ expect(page).to have_text('There is not a valid Git repository at this URL')
+ end
+
+ it 'initiates import when valid repo url is provided' do
+ stub_request(:get, "http://foo/bar/info/refs?service=git-upload-pack").to_return({ status: 200,
+ body: '001e# service=git-upload-pack',
+ headers: { 'Content-Type': 'application/x-git-upload-pack-advertisement' } })
+
+ fill_in 'project_import_url', with: 'http://foo/bar'
+
+ click_on 'Start import'
+ wait_for_requests
+
+ expect(page).to have_text('Import in progress')
+ end
+ end
+
context 'from GitHub' do
before do
first('.js-import-github').click
@@ -358,4 +404,47 @@ RSpec.describe 'New project', :js do
end
end
end
+
+ context 'from Bitbucket', :js do
+ shared_examples 'has a link to bitbucket cloud' do
+ context 'when bitbucket is not configured' do
+ before do
+ allow(Gitlab::Auth::OAuth::Provider).to receive(:enabled?).and_call_original
+ allow(Gitlab::Auth::OAuth::Provider)
+ .to receive(:enabled?).with(:bitbucket)
+ .and_return(false)
+
+ visit new_project_path
+ click_link 'Import project'
+ click_link 'Bitbucket Cloud'
+ end
+
+ it 'shows import instructions' do
+ expect(find('.modal-body')).to have_content(bitbucket_link_content)
+ end
+ end
+ end
+
+ context 'as a user' do
+ let(:user) { create(:user) }
+ let(:bitbucket_link_content) { 'To enable importing projects from Bitbucket, ask your GitLab administrator to configure OAuth integration' }
+
+ before do
+ sign_in(user)
+ end
+
+ it_behaves_like 'has a link to bitbucket cloud'
+ end
+
+ context 'as an admin' do
+ let(:user) { create(:admin) }
+ let(:bitbucket_link_content) { 'To enable importing projects from Bitbucket, as administrator you need to configure OAuth integration' }
+
+ before do
+ sign_in(user)
+ end
+
+ it_behaves_like 'has a link to bitbucket cloud'
+ end
+ end
end