2019-05-23 18:07:59 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2011-10-08 21:36:38 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 18:08:28 +00:00
|
|
|
RSpec.describe 'Project' do
|
2017-09-29 08:04:50 +00:00
|
|
|
include ProjectForksHelper
|
2018-09-06 07:27:39 +00:00
|
|
|
include MobileHelpers
|
2017-09-29 08:04:50 +00:00
|
|
|
|
2020-10-16 18:09:04 +00:00
|
|
|
describe 'template' do
|
2019-01-16 12:09:29 +00:00
|
|
|
let(:user) { create(:user) }
|
2017-07-26 12:21:53 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in user
|
|
|
|
visit new_project_path
|
|
|
|
end
|
|
|
|
|
2020-10-16 18:09:04 +00:00
|
|
|
shared_examples 'creates from template' do |template, sub_template_tab = nil|
|
|
|
|
it "is created from template", :js do
|
|
|
|
find('#create-from-template-tab').click
|
|
|
|
find(".project-template #{sub_template_tab}").click if sub_template_tab
|
|
|
|
find("label[for=#{template.name}]").click
|
|
|
|
fill_in("project_name", with: template.name)
|
2017-07-26 12:21:53 +00:00
|
|
|
|
2020-10-16 18:09:04 +00:00
|
|
|
page.within '#content-body' do
|
|
|
|
click_button "Create project"
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_content template.name
|
2017-07-26 12:21:53 +00:00
|
|
|
end
|
2020-10-16 18:09:04 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'create with project template' do
|
|
|
|
it_behaves_like 'creates from template', Gitlab::ProjectTemplate.find(:rails)
|
|
|
|
end
|
2017-07-26 12:21:53 +00:00
|
|
|
|
2020-10-16 18:09:04 +00:00
|
|
|
context 'create with sample data template' do
|
|
|
|
it_behaves_like 'creates from template', Gitlab::SampleDataTemplate.find(:basic), '.sample-data-templates-tab'
|
2017-07-26 12:21:53 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-23 09:00:19 +00:00
|
|
|
describe 'shows tip about push to create git command' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in user
|
|
|
|
visit new_project_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the command in a popover', :js do
|
|
|
|
page.within '.profile-settings-sidebar' do
|
|
|
|
click_link 'Show command'
|
|
|
|
end
|
|
|
|
|
|
|
|
expect(page).to have_css('.popover .push-to-create-popover #push_to_create_tip')
|
|
|
|
expect(page).to have_content 'Private projects can be created in your personal namespace with:'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-05-29 23:02:11 +00:00
|
|
|
describe 'description' do
|
2017-03-28 21:13:16 +00:00
|
|
|
let(:project) { create(:project, :repository) }
|
2017-07-06 16:20:50 +00:00
|
|
|
let(:path) { project_path(project) }
|
2011-10-08 21:36:38 +00:00
|
|
|
|
2012-05-27 10:39:57 +00:00
|
|
|
before do
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(create(:admin))
|
2012-05-27 10:39:57 +00:00
|
|
|
end
|
|
|
|
|
2015-05-29 23:02:11 +00:00
|
|
|
it 'parses Markdown' do
|
|
|
|
project.update_attribute(:description, 'This is **my** project')
|
|
|
|
visit path
|
2019-01-21 20:52:53 +00:00
|
|
|
expect(page).to have_css('.home-panel-description > .home-panel-description-markdown > p > strong')
|
2015-05-29 23:02:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'passes through html-pipeline' do
|
|
|
|
project.update_attribute(:description, 'This project is the :poop:')
|
|
|
|
visit path
|
2019-01-21 20:52:53 +00:00
|
|
|
expect(page).to have_css('.home-panel-description > .home-panel-description-markdown > p > gl-emoji')
|
2015-05-29 23:02:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'sanitizes unwanted tags' do
|
2015-08-06 15:15:37 +00:00
|
|
|
project.update_attribute(:description, "```\ncode\n```")
|
2015-05-29 23:02:11 +00:00
|
|
|
visit path
|
2019-01-21 20:52:53 +00:00
|
|
|
expect(page).not_to have_css('.home-panel-description code')
|
2015-05-29 23:02:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'permits `rel` attribute on links' do
|
|
|
|
project.update_attribute(:description, 'https://google.com/')
|
|
|
|
visit path
|
2019-01-21 20:52:53 +00:00
|
|
|
expect(page).to have_css('.home-panel-description a[rel]')
|
2018-09-06 07:27:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'read more', :js do
|
|
|
|
let(:read_more_selector) { '.read-more-container' }
|
2019-01-21 20:52:53 +00:00
|
|
|
let(:read_more_trigger_selector) { '.home-panel-home-desc .js-read-more-trigger' }
|
2018-09-06 07:27:39 +00:00
|
|
|
|
|
|
|
it 'does not display "read more" link on desktop breakpoint' do
|
|
|
|
project.update_attribute(:description, 'This is **my** project')
|
|
|
|
visit path
|
|
|
|
|
|
|
|
expect(find(read_more_trigger_selector, visible: false)).not_to be_visible
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays "read more" link on mobile breakpoint' do
|
|
|
|
project.update_attribute(:description, 'This is **my** project')
|
|
|
|
visit path
|
|
|
|
resize_screen_xs
|
|
|
|
|
|
|
|
find(read_more_trigger_selector).click
|
|
|
|
|
2019-01-21 20:52:53 +00:00
|
|
|
expect(page).to have_css('.home-panel-description .is-expanded')
|
2018-09-06 07:27:39 +00:00
|
|
|
end
|
|
|
|
end
|
2020-10-01 06:09:59 +00:00
|
|
|
|
|
|
|
context 'page description' do
|
|
|
|
before do
|
|
|
|
project.update_attribute(:description, '**Lorem** _ipsum_ dolor sit [amet](https://example.com)')
|
|
|
|
visit path
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'page meta description', 'Lorem ipsum dolor sit amet'
|
|
|
|
end
|
2019-01-14 10:26:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'project topics' do
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:path) { project_path(project) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(create(:admin))
|
|
|
|
visit path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows project topics' do
|
|
|
|
project.update_attribute(:tag_list, 'topic1')
|
2019-02-05 23:12:02 +00:00
|
|
|
|
2019-01-14 10:26:42 +00:00
|
|
|
visit path
|
2019-02-05 23:12:02 +00:00
|
|
|
|
2019-01-21 20:52:53 +00:00
|
|
|
expect(page).to have_css('.home-panel-topic-list')
|
2019-02-05 23:12:02 +00:00
|
|
|
expect(page).to have_link('Topic1', href: explore_projects_path(tag: 'topic1'))
|
2019-01-14 10:26:42 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows up to 3 project tags' do
|
|
|
|
project.update_attribute(:tag_list, 'topic1, topic2, topic3, topic4')
|
2019-02-05 23:12:02 +00:00
|
|
|
|
2019-01-14 10:26:42 +00:00
|
|
|
visit path
|
2019-02-05 23:12:02 +00:00
|
|
|
|
2019-01-21 20:52:53 +00:00
|
|
|
expect(page).to have_css('.home-panel-topic-list')
|
2019-02-05 23:12:02 +00:00
|
|
|
expect(page).to have_link('Topic1', href: explore_projects_path(tag: 'topic1'))
|
|
|
|
expect(page).to have_link('Topic2', href: explore_projects_path(tag: 'topic2'))
|
|
|
|
expect(page).to have_link('Topic3', href: explore_projects_path(tag: 'topic3'))
|
|
|
|
expect(page).to have_content('+ 1 more')
|
2019-01-14 10:26:42 +00:00
|
|
|
end
|
2018-09-06 07:27:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'copy clone URL to clipboard', :js do
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:path) { project_path(project) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(create(:admin))
|
|
|
|
visit path
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'desktop component' do
|
|
|
|
it 'shows on md and larger breakpoints' do
|
|
|
|
expect(find('.git-clone-holder')).to be_visible
|
|
|
|
expect(find('.mobile-git-clone', visible: false)).not_to be_visible
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'mobile component' do
|
|
|
|
it 'shows mobile component on sm and smaller breakpoints' do
|
|
|
|
resize_screen_xs
|
|
|
|
expect(find('.mobile-git-clone')).to be_visible
|
|
|
|
expect(find('.git-clone-holder', visible: false)).not_to be_visible
|
|
|
|
end
|
2015-05-29 23:02:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
describe 'remove forked relationship', :js do
|
2015-10-13 10:24:44 +00:00
|
|
|
let(:user) { create(:user) }
|
2020-08-26 00:10:31 +00:00
|
|
|
let(:project) { fork_project(create(:project, :public), user, namespace: user.namespace) }
|
2015-10-13 10:24:44 +00:00
|
|
|
|
|
|
|
before do
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in user
|
2017-07-06 16:20:50 +00:00
|
|
|
visit edit_project_path(project)
|
2015-10-13 10:24:44 +00:00
|
|
|
end
|
|
|
|
|
2016-07-25 18:16:19 +00:00
|
|
|
it 'removes fork' do
|
2015-10-13 22:04:22 +00:00
|
|
|
expect(page).to have_content 'Remove fork relationship'
|
2015-10-13 10:24:44 +00:00
|
|
|
|
2015-10-13 22:04:22 +00:00
|
|
|
remove_with_confirm('Remove fork relationship', project.path)
|
2015-10-13 10:24:44 +00:00
|
|
|
|
2015-10-18 12:12:50 +00:00
|
|
|
expect(page).to have_content 'The fork relationship has been removed.'
|
2017-09-29 08:04:50 +00:00
|
|
|
expect(project.reload.forked?).to be_falsey
|
2015-10-13 22:04:22 +00:00
|
|
|
expect(page).not_to have_content 'Remove fork relationship'
|
2015-10-13 10:24:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 17:41:37 +00:00
|
|
|
describe 'showing information about source of a project fork' do
|
|
|
|
let(:user) { create(:user) }
|
2019-01-16 12:09:29 +00:00
|
|
|
let(:base_project) { create(:project, :public, :repository) }
|
2017-10-03 17:41:37 +00:00
|
|
|
let(:forked_project) { fork_project(base_project, user, repository: true) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in user
|
|
|
|
end
|
|
|
|
|
2019-10-23 09:06:03 +00:00
|
|
|
it 'shows a link to the source project when it is available', :sidekiq_might_not_need_inline do
|
2017-10-03 17:41:37 +00:00
|
|
|
visit project_path(forked_project)
|
|
|
|
|
|
|
|
expect(page).to have_content('Forked from')
|
|
|
|
expect(page).to have_link(base_project.full_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not contain fork network information for the root project' do
|
|
|
|
forked_project
|
|
|
|
|
|
|
|
visit project_path(base_project)
|
|
|
|
|
|
|
|
expect(page).not_to have_content('In fork network of')
|
|
|
|
expect(page).not_to have_content('Forked from')
|
|
|
|
end
|
|
|
|
|
2019-11-19 16:17:35 +00:00
|
|
|
it 'does not show the name of the deleted project when the source was deleted', :sidekiq_might_not_need_inline do
|
2017-10-03 17:41:37 +00:00
|
|
|
forked_project
|
|
|
|
Projects::DestroyService.new(base_project, base_project.owner).execute
|
|
|
|
|
|
|
|
visit project_path(forked_project)
|
|
|
|
|
2019-11-19 16:17:35 +00:00
|
|
|
expect(page).to have_content('Forked from an inaccessible project')
|
2017-10-03 17:41:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'a fork of a fork' do
|
|
|
|
let(:fork_of_fork) { fork_project(forked_project, user, repository: true) }
|
|
|
|
|
2019-10-23 09:06:03 +00:00
|
|
|
it 'links to the base project if the source project is removed', :sidekiq_might_not_need_inline do
|
2017-10-03 17:41:37 +00:00
|
|
|
fork_of_fork
|
|
|
|
Projects::DestroyService.new(forked_project, user).execute
|
|
|
|
|
|
|
|
visit project_path(fork_of_fork)
|
|
|
|
|
|
|
|
expect(page).to have_content("Forked from")
|
|
|
|
expect(page).to have_link(base_project.full_name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-14 13:07:12 +00:00
|
|
|
describe 'when the project repository is disabled', :js do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :repository_disabled, :repository, namespace: user.namespace) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
project.add_maintainer(user)
|
|
|
|
visit project_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not show an error' do
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.flash-alert')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
describe 'removal', :js do
|
2018-02-22 11:57:56 +00:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, namespace: user.namespace) }
|
2015-05-29 23:02:11 +00:00
|
|
|
|
|
|
|
before do
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-07-06 16:20:50 +00:00
|
|
|
visit edit_project_path(project)
|
2015-05-29 23:02:11 +00:00
|
|
|
end
|
|
|
|
|
2018-07-06 14:14:31 +00:00
|
|
|
it 'focuses on the confirmation field' do
|
2020-08-12 21:09:54 +00:00
|
|
|
click_button 'Delete project'
|
2018-07-06 14:14:31 +00:00
|
|
|
|
|
|
|
expect(page).to have_selector '#confirm_name_input:focus'
|
|
|
|
end
|
|
|
|
|
2020-08-12 21:09:54 +00:00
|
|
|
it 'deletes a project', :sidekiq_might_not_need_inline do
|
2020-11-11 12:09:06 +00:00
|
|
|
expect { remove_with_confirm('Delete project', project.path, 'Yes, delete project') }.to change { Project.count }.by(-1)
|
2018-02-22 11:57:56 +00:00
|
|
|
expect(page).to have_content "Project '#{project.full_name}' is in the process of being deleted."
|
2016-09-02 12:15:18 +00:00
|
|
|
expect(Project.all.count).to be_zero
|
|
|
|
expect(project.issues).to be_empty
|
|
|
|
expect(project.merge_requests).to be_empty
|
2012-05-27 10:39:57 +00:00
|
|
|
end
|
|
|
|
end
|
2014-10-28 18:02:01 +00:00
|
|
|
|
2019-11-18 18:06:53 +00:00
|
|
|
describe 'tree view (default view is set to Files)', :js do
|
2016-08-22 16:19:39 +00:00
|
|
|
let(:user) { create(:user, project_view: 'files') }
|
|
|
|
let(:project) { create(:forked_project_with_submodules) }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in user
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_path(project)
|
2016-08-22 16:19:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has working links to files' do
|
|
|
|
click_link('PROCESS.md')
|
|
|
|
|
2019-11-18 18:06:53 +00:00
|
|
|
expect(page).to have_selector('.file-holder')
|
2016-08-22 16:19:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has working links to directories' do
|
|
|
|
click_link('encoding')
|
|
|
|
|
2019-11-18 18:06:53 +00:00
|
|
|
expect(page).to have_selector('.breadcrumb-item', text: 'encoding')
|
2016-08-22 16:19:39 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'has working links to submodules' do
|
|
|
|
click_link('645f6c4c')
|
|
|
|
|
2019-11-18 18:06:53 +00:00
|
|
|
expect(page).to have_selector('.qa-branches-select', text: '645f6c4c82fd3f5e06f67134450a570b795e55a6')
|
2016-08-22 16:19:39 +00:00
|
|
|
end
|
2018-08-02 16:17:20 +00:00
|
|
|
|
|
|
|
context 'for signed commit on default branch', :js do
|
|
|
|
before do
|
|
|
|
project.change_head('33f3729a45c02fc67d00adb1b8bca394b0e761d9')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays a GPG badge' do
|
|
|
|
visit project_path(project)
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
|
|
|
|
expect(page).to have_selector '.gpg-status-box.invalid'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-24 09:20:54 +00:00
|
|
|
context 'for subgroups', :js do
|
2018-08-02 16:17:20 +00:00
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:subgroup) { create(:group, parent: group) }
|
|
|
|
let(:project) { create(:project, :repository, group: subgroup) }
|
|
|
|
|
|
|
|
it 'renders tree table without errors' do
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).to have_selector('.tree-item')
|
|
|
|
expect(page).not_to have_selector('.flash-alert')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for signed commit' do
|
|
|
|
before do
|
|
|
|
repository = project.repository
|
|
|
|
repository.write_ref("refs/heads/#{project.default_branch}", '33f3729a45c02fc67d00adb1b8bca394b0e761d9')
|
|
|
|
repository.expire_branches_cache
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'displays a GPG badge' do
|
|
|
|
visit project_path(project)
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
|
|
|
|
expect(page).to have_selector '.gpg-status-box.invalid'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-08-22 16:19:39 +00:00
|
|
|
end
|
|
|
|
|
2017-08-08 11:43:45 +00:00
|
|
|
describe 'activity view' do
|
|
|
|
let(:user) { create(:user, project_view: 'activity') }
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-08-08 11:43:45 +00:00
|
|
|
sign_in user
|
|
|
|
visit project_path(project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'loads activity', :js do
|
|
|
|
expect(page).to have_selector('.event-item')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-18 11:28:12 +00:00
|
|
|
context 'content is not cached after signing out', :js do
|
|
|
|
let(:user) { create(:user, project_view: 'activity') }
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
|
|
|
|
it 'does not load activity', :js do
|
|
|
|
project.add_maintainer(user)
|
|
|
|
sign_in(user)
|
|
|
|
visit project_path(project)
|
|
|
|
sign_out(user)
|
|
|
|
|
|
|
|
page.evaluate_script('window.history.back()')
|
|
|
|
|
|
|
|
expect(page).not_to have_selector('.event-item')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-14 20:52:01 +00:00
|
|
|
describe 'edit' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
let(:path) { edit_project_path(project) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_maintainer(user)
|
|
|
|
sign_in(user)
|
|
|
|
visit path
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'dirty submit form', [{ form: '.js-general-settings-form', input: 'input[name="project[name]"]' },
|
2019-07-26 21:59:27 +00:00
|
|
|
{ form: '.rspec-merge-request-settings', input: '#project_printing_merge_request_link_enabled' }]
|
2019-03-14 20:52:01 +00:00
|
|
|
end
|
|
|
|
|
2020-08-04 12:09:48 +00:00
|
|
|
def remove_with_confirm(button_text, confirm_with, confirm_button_text = 'Confirm')
|
2015-10-13 10:24:44 +00:00
|
|
|
click_button button_text
|
|
|
|
fill_in 'confirm_name_input', with: confirm_with
|
2020-08-04 12:09:48 +00:00
|
|
|
click_button confirm_button_text
|
2014-10-28 18:02:01 +00:00
|
|
|
end
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|