debian-mirror-gitlab/spec/features/projects/new_project_spec.rb

582 lines
19 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require 'spec_helper'
2016-11-24 13:41:30 +05:30
2021-02-22 17:27:13 +05:30
RSpec.describe 'New project', :js do
2021-09-04 01:27:46 +05:30
include Spec::Support::Helpers::Features::TopNavSpecHelpers
2018-03-17 18:26:18 +05:30
2021-10-27 15:23:28 +05:30
context 'as a user' do
2022-08-27 11:52:29 +05:30
let_it_be(:user) { create(:user) }
2016-11-24 13:41:30 +05:30
2021-10-27 15:23:28 +05:30
before do
sign_in(user)
end
2021-04-29 21:17:54 +05:30
2022-08-27 11:52:29 +05:30
it 'shows the project description field when it should' do
description_label = 'Project description (optional)'
visit new_project_path
click_link 'Create blank project'
page.within('#blank-project-pane') do
expect(page).not_to have_content(description_label)
end
visit new_project_path
click_link 'Import project'
page.within('#import-project-pane') do
click_button 'Repository by URL'
expect(page).to have_content(description_label)
end
visit new_project_path
click_link 'Create from template'
page.within('#create-from-template-pane') do
find("[data-testid='use_template_#{Gitlab::ProjectTemplate.localized_templates_table.first.name}']").click
expect(page).to have_content(description_label)
end
end
2021-10-27 15:23:28 +05:30
it 'shows a message if multiple levels are restricted' do
Gitlab::CurrentSettings.update!(
restricted_visibility_levels: [Gitlab::VisibilityLevel::PRIVATE, Gitlab::VisibilityLevel::INTERNAL]
)
2017-09-10 17:25:29 +05:30
2021-10-27 15:23:28 +05:30
visit new_project_path
2021-12-11 22:18:48 +05:30
click_link 'Create blank project'
2018-03-17 18:26:18 +05:30
2021-10-27 15:23:28 +05:30
expect(page).to have_content 'Other visibility settings have been disabled by the administrator.'
end
2017-09-10 17:25:29 +05:30
2021-10-27 15:23:28 +05:30
it 'shows a message if all levels are restricted' do
Gitlab::CurrentSettings.update!(
restricted_visibility_levels: Gitlab::VisibilityLevel.values
)
2018-11-18 11:00:15 +05:30
2021-10-27 15:23:28 +05:30
visit new_project_path
2021-12-11 22:18:48 +05:30
click_link 'Create blank project'
2018-11-18 11:00:15 +05:30
2021-10-27 15:23:28 +05:30
expect(page).to have_content 'Visibility settings have been disabled by the administrator.'
2018-11-18 11:00:15 +05:30
end
2021-10-27 15:23:28 +05:30
end
2018-11-18 11:00:15 +05:30
2021-10-27 15:23:28 +05:30
context 'as an admin' do
let(:user) { create(:admin) }
2017-08-17 22:00:37 +05:30
2021-10-27 15:23:28 +05:30
before do
sign_in(user)
end
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
it 'shows "New project" page', :js do
visit new_project_path
2021-12-11 22:18:48 +05:30
click_link 'Create blank project'
2019-09-30 21:07:59 +05:30
2021-10-27 15:23:28 +05:30
expect(page).to have_content('Project name')
expect(page).to have_content('Project URL')
expect(page).to have_content('Project slug')
2019-09-04 21:01:54 +05:30
2021-10-27 15:23:28 +05:30
click_link('New project')
2021-12-11 22:18:48 +05:30
click_link 'Import project'
2019-09-04 21:01:54 +05:30
2021-10-27 15:23:28 +05:30
expect(page).to have_link('GitHub')
expect(page).to have_link('Bitbucket')
expect(page).to have_link('GitLab.com')
2022-07-23 23:45:48 +05:30
expect(page).to have_button('Repository by URL')
2021-10-27 15:23:28 +05:30
expect(page).to have_link('GitLab export')
end
2019-09-30 21:07:59 +05:30
2022-08-13 15:12:31 +05:30
shared_examples 'renders importer link' do |params|
2022-07-23 23:45:48 +05:30
context 'with user namespace' do
before do
visit new_project_path
click_link 'Import project'
end
2022-08-13 15:12:31 +05:30
it "renders link to #{params[:name]} importer" do
expect(page).to have_link(href: Rails.application.routes.url_helpers.send(params[:route]))
2022-07-23 23:45:48 +05:30
end
end
context 'with group namespace' do
let(:group) { create(:group, :private) }
before do
group.add_owner(user)
visit new_project_path(namespace_id: group.id)
click_link 'Import project'
end
2022-08-13 15:12:31 +05:30
it "renders link to #{params[:name]} importer including namespace id" do
expect(page).to have_link(href: Rails.application.routes.url_helpers.send(params[:route], namespace_id: group.id))
2022-07-23 23:45:48 +05:30
end
end
end
2022-08-13 15:12:31 +05:30
describe 'importer links' do
shared_examples 'link to importers' do
let(:importer_routes) do
{
'github': :new_import_github_path,
'bitbucket': :status_import_bitbucket_path,
'bitbucket server': :status_import_bitbucket_server_path,
'gitlab.com': :status_import_gitlab_path,
'fogbugz': :new_import_fogbugz_path,
'gitea': :new_import_gitea_path,
'manifest': :new_import_manifest_path,
'phabricator': :new_import_phabricator_path
}
end
2019-09-04 21:01:54 +05:30
2022-08-13 15:12:31 +05:30
it 'renders links to several importers', :aggregate_failures do
importer_routes.each_value do |route|
expect(page).to have_link(href: Rails.application.routes.url_helpers.send(route, link_params))
end
end
2021-10-27 15:23:28 +05:30
end
2019-09-04 21:01:54 +05:30
2022-08-13 15:12:31 +05:30
context 'with user namespace' do
let(:link_params) { {} }
before do
visit new_project_path
click_link 'Import project'
end
include_examples 'link to importers'
end
context 'with group namespace' do
let(:group) { create(:group, :private) }
let(:link_params) { { namespace_id: group.id } }
before do
group.add_owner(user)
visit new_project_path(namespace_id: group.id)
click_link 'Import project'
end
include_examples 'link to importers'
2019-09-04 21:01:54 +05:30
end
2021-10-27 15:23:28 +05:30
end
2017-08-17 22:00:37 +05:30
2021-10-27 15:23:28 +05:30
context 'Visibility level selector', :js do
Gitlab::VisibilityLevel.options.each do |key, level|
it "sets selector to #{key}" do
stub_application_setting(default_project_visibility: level)
2021-04-17 20:07:23 +05:30
2021-10-27 15:23:28 +05:30
visit new_project_path
2021-12-11 22:18:48 +05:30
click_link 'Create blank project'
2021-10-27 15:23:28 +05:30
page.within('#blank-project-pane') do
expect(find_field("project_visibility_level_#{level}")).to be_checked
2021-06-08 01:23:25 +05:30
end
2021-10-27 15:23:28 +05:30
end
2018-11-08 19:23:39 +05:30
2021-10-27 15:23:28 +05:30
it "saves visibility level #{level} on validation error" do
visit new_project_path
2021-12-11 22:18:48 +05:30
click_link 'Create blank project'
2018-12-05 23:21:45 +05:30
2021-10-27 15:23:28 +05:30
choose(key)
click_button('Create project')
page.within('#blank-project-pane') do
expect(find_field("project_visibility_level_#{level}")).to be_checked
2021-04-17 20:07:23 +05:30
end
end
2021-10-27 15:23:28 +05:30
end
2021-04-17 20:07:23 +05:30
2021-10-27 15:23:28 +05:30
context 'when group visibility is private but default is internal' do
let_it_be(:group) { create(:group, visibility_level: Gitlab::VisibilityLevel::PRIVATE) }
2021-04-17 20:07:23 +05:30
2021-10-27 15:23:28 +05:30
before do
stub_application_setting(default_project_visibility: Gitlab::VisibilityLevel::INTERNAL)
end
2019-09-30 21:07:59 +05:30
2021-10-27 15:23:28 +05:30
context 'when admin mode is enabled', :enable_admin_mode do
it 'has private selected' do
visit new_project_path(namespace_id: group.id)
2021-12-11 22:18:48 +05:30
click_link 'Create blank project'
2021-04-17 20:07:23 +05:30
2021-10-27 15:23:28 +05:30
page.within('#blank-project-pane') do
expect(find_field("project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).to be_checked
2021-06-08 01:23:25 +05:30
end
end
2021-10-27 15:23:28 +05:30
end
2018-12-05 23:21:45 +05:30
2021-10-27 15:23:28 +05:30
context 'when admin mode is disabled' do
it 'is not allowed' do
visit new_project_path(namespace_id: group.id)
2019-09-30 21:07:59 +05:30
2021-10-27 15:23:28 +05:30
expect(page).to have_content('Not Found')
2021-04-17 20:07:23 +05:30
end
end
2021-10-27 15:23:28 +05:30
end
2021-04-17 20:07:23 +05:30
2021-10-27 15:23:28 +05:30
context 'when group visibility is public but user requests private' do
let_it_be(:group) { create(:group, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
2021-04-17 20:07:23 +05:30
2021-10-27 15:23:28 +05:30
before do
stub_application_setting(default_project_visibility: Gitlab::VisibilityLevel::INTERNAL)
end
2018-12-05 23:21:45 +05:30
2021-10-27 15:23:28 +05:30
context 'when admin mode is enabled', :enable_admin_mode do
it 'has private selected' do
visit new_project_path(namespace_id: group.id, project: { visibility_level: Gitlab::VisibilityLevel::PRIVATE })
2021-12-11 22:18:48 +05:30
click_link 'Create blank project'
2018-12-05 23:21:45 +05:30
2021-10-27 15:23:28 +05:30
page.within('#blank-project-pane') do
expect(find_field("project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).to be_checked
2021-06-08 01:23:25 +05:30
end
end
2021-10-27 15:23:28 +05:30
end
2018-11-08 19:23:39 +05:30
2021-10-27 15:23:28 +05:30
context 'when admin mode is disabled' do
it 'is not allowed' do
visit new_project_path(namespace_id: group.id, project: { visibility_level: Gitlab::VisibilityLevel::PRIVATE })
2019-09-30 21:07:59 +05:30
2021-10-27 15:23:28 +05:30
expect(page).to have_content('Not Found')
2021-06-08 01:23:25 +05:30
end
2019-09-30 21:07:59 +05:30
end
2017-08-17 22:00:37 +05:30
end
2021-10-27 15:23:28 +05:30
end
2017-08-17 22:00:37 +05:30
2021-10-27 15:23:28 +05:30
context 'Readme selector' do
it 'shows the initialize with Readme checkbox on "Blank project" tab' do
visit new_project_path
2021-12-11 22:18:48 +05:30
click_link 'Create blank project'
2017-08-17 22:00:37 +05:30
2021-10-27 15:23:28 +05:30
expect(page).to have_css('input#project_initialize_with_readme')
expect(page).to have_content('Initialize repository with a README')
end
2017-08-17 22:00:37 +05:30
2021-10-27 15:23:28 +05:30
it 'does not show the initialize with Readme checkbox on "Create from template" tab' do
visit new_project_path
2021-12-11 22:18:48 +05:30
click_link 'Create from template'
2021-10-27 15:23:28 +05:30
first('.choose-template').click
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
page.within '.project-fields-form' do
expect(page).not_to have_css('input#project_initialize_with_readme')
expect(page).not_to have_content('Initialize repository with a README')
2019-09-30 21:07:59 +05:30
end
2021-10-27 15:23:28 +05:30
end
2017-08-17 22:00:37 +05:30
2021-10-27 15:23:28 +05:30
it 'does not show the initialize with Readme checkbox on "Import project" tab' do
visit new_project_path
2021-12-11 22:18:48 +05:30
click_link 'Import project'
2022-07-23 23:45:48 +05:30
click_button 'Repository by URL'
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
page.within '#import-project-pane' do
expect(page).not_to have_css('input#project_initialize_with_readme')
expect(page).not_to have_content('Initialize repository with a README')
2019-09-30 21:07:59 +05:30
end
2017-08-17 22:00:37 +05:30
end
2021-10-27 15:23:28 +05:30
end
2017-08-17 22:00:37 +05:30
2021-10-27 15:23:28 +05:30
context 'Namespace selector' do
context 'with user namespace' do
before do
visit new_project_path
2021-12-11 22:18:48 +05:30
click_link 'Create blank project'
2021-10-27 15:23:28 +05:30
end
2017-08-17 22:00:37 +05:30
2022-06-21 17:19:12 +05:30
it 'does not select the user namespace' do
click_on 'Pick a group or namespace'
2022-03-02 08:16:31 +05:30
expect(page).to have_button user.username
2017-08-17 22:00:37 +05:30
end
2021-10-27 15:23:28 +05:30
end
2017-08-17 22:00:37 +05:30
2021-10-27 15:23:28 +05:30
context 'with group namespace' do
let(:group) { create(:group, :private) }
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
before do
group.add_owner(user)
visit new_project_path(namespace_id: group.id)
2021-12-11 22:18:48 +05:30
click_link 'Create blank project'
2021-10-27 15:23:28 +05:30
end
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
it 'selects the group namespace' do
2022-03-02 08:16:31 +05:30
expect(page).to have_button group.name
2019-09-30 21:07:59 +05:30
end
2021-10-27 15:23:28 +05:30
end
2017-08-17 22:00:37 +05:30
2021-10-27 15:23:28 +05:30
context 'with subgroup namespace' do
let(:group) { create(:group) }
let(:subgroup) { create(:group, parent: group) }
2018-03-17 18:26:18 +05:30
2021-10-27 15:23:28 +05:30
before do
group.add_maintainer(user)
visit new_project_path(namespace_id: subgroup.id)
2021-12-11 22:18:48 +05:30
click_link 'Create blank project'
2019-09-30 21:07:59 +05:30
end
2017-08-17 22:00:37 +05:30
2021-10-27 15:23:28 +05:30
it 'selects the group namespace' do
2022-03-02 08:16:31 +05:30
expect(page).to have_button subgroup.full_path
2019-09-30 21:07:59 +05:30
end
end
2017-08-17 22:00:37 +05:30
2021-10-27 15:23:28 +05:30
context 'when changing namespaces dynamically', :js do
let(:public_group) { create(:group, :public) }
let(:internal_group) { create(:group, :internal) }
let(:private_group) { create(:group, :private) }
2019-09-30 21:07:59 +05:30
before do
2021-10-27 15:23:28 +05:30
public_group.add_owner(user)
internal_group.add_owner(user)
private_group.add_owner(user)
visit new_project_path(namespace_id: public_group.id)
2021-12-11 22:18:48 +05:30
click_link 'Create blank project'
2019-09-30 21:07:59 +05:30
end
2021-10-27 15:23:28 +05:30
it 'enables the correct visibility options' do
2022-03-02 08:16:31 +05:30
click_button public_group.full_path
click_button user.username
2021-10-27 15:23:28 +05:30
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).not_to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::INTERNAL}")).not_to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PUBLIC}")).not_to be_disabled
2022-03-02 08:16:31 +05:30
click_button user.username
click_button public_group.full_path
2021-10-27 15:23:28 +05:30
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).not_to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::INTERNAL}")).not_to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PUBLIC}")).not_to be_disabled
2022-03-02 08:16:31 +05:30
click_button public_group.full_path
click_button internal_group.full_path
2021-10-27 15:23:28 +05:30
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).not_to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::INTERNAL}")).not_to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PUBLIC}")).to be_disabled
2022-03-02 08:16:31 +05:30
click_button internal_group.full_path
click_button private_group.full_path
2021-10-27 15:23:28 +05:30
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).not_to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::INTERNAL}")).to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PUBLIC}")).to be_disabled
end
end
end
2017-08-17 22:00:37 +05:30
2022-07-23 23:45:48 +05:30
context 'Import project options without any sources', :js do
before do
stub_application_setting(import_sources: [])
visit new_project_path
click_link 'Import project'
end
it 'displays the no import options message' do
expect(page).to have_text s_('ProjectsNew|No import options available')
expect(page).to have_text s_('ProjectsNew|Contact an administrator to enable options for importing your project.')
end
end
2021-10-27 15:23:28 +05:30
context 'Import project options', :js do
before do
visit new_project_path
2021-12-11 22:18:48 +05:30
click_link 'Import project'
2021-10-27 15:23:28 +05:30
end
2018-03-27 19:54:05 +05:30
2022-07-23 23:45:48 +05:30
context 'from git repository url, "Repository by URL"' do
2021-10-27 15:23:28 +05:30
before do
first('.js-import-git-toggle-button').click
end
2018-03-27 19:54:05 +05:30
2021-10-27 15:23:28 +05:30
it 'does not autocomplete sensitive git repo URL' do
autocomplete = find('#project_import_url')['autocomplete']
2021-09-30 23:02:18 +05:30
2021-10-27 15:23:28 +05:30
expect(autocomplete).to eq('off')
end
2021-09-30 23:02:18 +05:30
2021-10-27 15:23:28 +05:30
it 'shows import instructions' do
git_import_instructions = first('.js-toggle-content')
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
expect(git_import_instructions).to be_visible
expect(git_import_instructions).to have_content 'Git repository URL'
end
2021-06-08 01:23:25 +05:30
2021-11-18 22:05:49 +05:30
it 'reports error if repo URL is not a valid Git repository' do
stub_request(:get, "http://foo/bar/info/refs?service=git-upload-pack").to_return(status: 200, body: "not-a-git-repo")
2021-10-27 15:23:28 +05:30
fill_in 'project_import_url', with: 'http://foo/bar'
# simulate blur event
find('body').click
2017-09-10 17:25:29 +05:30
2021-11-18 22:05:49 +05:30
wait_for_requests
expect(page).to have_text('There is not a valid Git repository at this URL')
2019-09-30 21:07:59 +05:30
end
2017-09-10 17:25:29 +05:30
2022-04-04 11:22:00 +05:30
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
2021-10-27 15:23:28 +05:30
it 'keeps "Import project" tab open after form validation error' do
collision_project = create(:project, name: 'test-name-collision', namespace: user.namespace)
2022-10-11 01:57:18 +05:30
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' } })
2021-06-08 01:23:25 +05:30
2022-04-04 11:22:00 +05:30
fill_in 'project_import_url', with: 'http://foo/bar'
2021-10-27 15:23:28 +05:30
fill_in 'project_name', with: collision_project.name
2018-11-18 11:00:15 +05:30
2021-10-27 15:23:28 +05:30
click_on 'Create project'
2021-06-08 01:23:25 +05:30
2022-06-21 17:19:12 +05:30
expect(page).to have_content(
s_('ProjectsNew|Pick a group or namespace where you want to create this project.')
)
click_on 'Pick a group or namespace'
click_on user.username
click_on 'Create project'
2021-10-27 15:23:28 +05:30
expect(page).to have_css('#import-project-pane.active')
expect(page).not_to have_css('.toggle-import-form.hide')
2019-09-30 21:07:59 +05:30
end
2018-11-18 11:00:15 +05:30
end
2019-07-07 11:18:12 +05:30
2022-04-04 11:22:00 +05:30
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
2022-10-11 01:57:18 +05:30
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' } })
2022-04-04 11:22:00 +05:30
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
2021-10-27 15:23:28 +05:30
context 'from GitHub' do
before do
first('.js-import-github').click
end
2019-07-07 11:18:12 +05:30
2021-10-27 15:23:28 +05:30
it 'shows import instructions' do
expect(page).to have_content('Authenticate with GitHub')
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path new_import_github_path, ignore_query: true
2019-07-07 11:18:12 +05:30
end
end
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
context 'from manifest file' do
before do
first('.import_manifest').click
end
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
it 'shows import instructions' do
expect(page).to have_content('Manifest file import')
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path new_import_manifest_path, ignore_query: true
2021-10-27 15:23:28 +05:30
end
end
2021-06-08 01:23:25 +05:30
end
2021-10-27 15:23:28 +05:30
context 'Namespace selector' do
context 'with group with DEVELOPER_MAINTAINER_PROJECT_ACCESS project_creation_level' do
let(:group) { create(:group, project_creation_level: ::Gitlab::Access::DEVELOPER_MAINTAINER_PROJECT_ACCESS) }
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
before do
group.add_developer(user)
visit new_project_path(namespace_id: group.id)
2021-12-11 22:18:48 +05:30
click_link 'Create blank project'
2021-10-27 15:23:28 +05:30
end
2021-06-08 01:23:25 +05:30
2021-10-27 15:23:28 +05:30
it 'selects the group namespace' do
2022-03-02 08:16:31 +05:30
expect(page).to have_button group.full_path
2021-10-27 15:23:28 +05:30
end
end
2021-06-08 01:23:25 +05:30
end
end
2022-04-04 11:22:00 +05:30
2022-05-07 20:08:51 +05:30
shared_examples 'has instructions to enable OAuth' do
context 'when OAuth is not configured' do
before do
sign_in(user)
2022-04-04 11:22:00 +05:30
2022-05-07 20:08:51 +05:30
allow(Gitlab::Auth::OAuth::Provider).to receive(:enabled?).and_call_original
allow(Gitlab::Auth::OAuth::Provider)
.to receive(:enabled?).with(provider)
.and_return(false)
2022-04-04 11:22:00 +05:30
2022-05-07 20:08:51 +05:30
visit new_project_path
click_link 'Import project'
click_link target_link
end
it 'shows import instructions' do
expect(find('.modal-body')).to have_content(oauth_config_instructions)
2022-04-04 11:22:00 +05:30
end
end
2022-05-07 20:08:51 +05:30
end
context 'from Bitbucket', :js do
let(:target_link) { 'Bitbucket Cloud' }
let(:provider) { :bitbucket }
2022-04-04 11:22:00 +05:30
context 'as a user' do
let(:user) { create(:user) }
2022-05-07 20:08:51 +05:30
let(:oauth_config_instructions) { 'To enable importing projects from Bitbucket, ask your GitLab administrator to configure OAuth integration' }
2022-04-04 11:22:00 +05:30
2022-05-07 20:08:51 +05:30
it_behaves_like 'has instructions to enable OAuth'
2022-04-04 11:22:00 +05:30
end
context 'as an admin' do
let(:user) { create(:admin) }
2022-05-07 20:08:51 +05:30
let(:oauth_config_instructions) { 'To enable importing projects from Bitbucket, as administrator you need to configure OAuth integration' }
2022-04-04 11:22:00 +05:30
2022-05-07 20:08:51 +05:30
it_behaves_like 'has instructions to enable OAuth'
end
end
context 'from GitLab.com', :js do
let(:target_link) { 'GitLab.com' }
let(:provider) { :gitlab }
context 'as a user' do
let(:user) { create(:user) }
let(:oauth_config_instructions) { 'To enable importing projects from GitLab.com, ask your GitLab administrator to configure OAuth integration' }
it_behaves_like 'has instructions to enable OAuth'
end
context 'as an admin' do
let(:user) { create(:admin) }
let(:oauth_config_instructions) { 'To enable importing projects from GitLab.com, as administrator you need to configure OAuth integration' }
2022-04-04 11:22:00 +05:30
2022-05-07 20:08:51 +05:30
it_behaves_like 'has instructions to enable OAuth'
2022-04-04 11:22:00 +05:30
end
end
2016-11-24 13:41:30 +05:30
end