2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2011-10-08 17:36:38 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2019-01-16 07:09:29 -05:00
|
|
|
describe "Admin::Projects" do
|
2016-12-19 06:29:58 -05:00
|
|
|
include Select2Helper
|
|
|
|
|
|
|
|
let(:user) { create :user }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project) }
|
2017-07-21 16:55:17 -04:00
|
|
|
let(:current_user) { create(:admin) }
|
2017-06-21 19:44:10 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(current_user)
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /admin/projects" do
|
2017-08-02 15:55:11 -04:00
|
|
|
let!(:archived_project) { create :project, :public, :archived }
|
2016-12-19 06:29:58 -05:00
|
|
|
|
2011-10-26 09:46:25 -04:00
|
|
|
before do
|
2017-07-21 16:55:17 -04:00
|
|
|
expect(project).to be_persisted
|
2016-12-08 13:59:41 -05:00
|
|
|
visit admin_projects_path
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it "is ok" do
|
2016-12-08 13:59:41 -05:00
|
|
|
expect(current_path).to eq(admin_projects_path)
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2016-12-19 06:29:58 -05:00
|
|
|
it 'renders projects list without archived project' do
|
|
|
|
expect(page).to have_content(project.name)
|
|
|
|
expect(page).not_to have_content(archived_project.name)
|
|
|
|
end
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
it 'renders all projects', :js do
|
2016-12-19 06:29:58 -05:00
|
|
|
find(:css, '#sort-projects-dropdown').click
|
|
|
|
click_link 'Show archived projects'
|
|
|
|
|
|
|
|
expect(page).to have_content(project.name)
|
|
|
|
expect(page).to have_content(archived_project.name)
|
2018-04-23 16:37:26 -04:00
|
|
|
expect(page).to have_xpath("//span[@class='badge badge-warning']", text: 'archived')
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
2017-08-11 05:09:17 -04:00
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
it 'renders only archived projects', :js do
|
2017-08-11 05:09:17 -04:00
|
|
|
find(:css, '#sort-projects-dropdown').click
|
|
|
|
click_link 'Show archived projects only'
|
|
|
|
|
|
|
|
expect(page).to have_content(archived_project.name)
|
|
|
|
expect(page).not_to have_content(project.name)
|
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2016-12-19 06:29:58 -05:00
|
|
|
describe "GET /admin/projects/:namespace_id/:id" do
|
2011-10-26 09:46:25 -04:00
|
|
|
before do
|
2017-07-21 16:55:17 -04:00
|
|
|
expect(project).to be_persisted
|
2016-12-19 06:29:58 -05:00
|
|
|
|
2017-07-21 16:55:17 -04:00
|
|
|
visit admin_projects_path
|
|
|
|
click_link project.name
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it "has project info" do
|
2017-07-21 16:55:17 -04:00
|
|
|
expect(current_path).to eq admin_project_path(project)
|
2016-12-19 06:29:58 -05:00
|
|
|
expect(page).to have_content(project.path)
|
|
|
|
expect(page).to have_content(project.name)
|
2018-03-05 09:15:26 -05:00
|
|
|
expect(page).to have_content(project.full_name)
|
2016-12-19 06:29:58 -05:00
|
|
|
expect(page).to have_content(project.creator.name)
|
2019-07-22 08:50:46 -04:00
|
|
|
expect(page).to have_content(project.id)
|
2016-12-19 06:29:58 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'transfer project' do
|
2017-07-21 16:55:17 -04:00
|
|
|
# The gitlab-shell transfer will fail for a project without a repository
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
|
2016-12-19 06:29:58 -05:00
|
|
|
before do
|
|
|
|
create(:group, name: 'Web')
|
|
|
|
|
2017-06-21 09:48:12 -04:00
|
|
|
allow_any_instance_of(Projects::TransferService)
|
|
|
|
.to receive(:move_uploads_to_new_namespace).and_return(true)
|
2016-12-19 06:29:58 -05:00
|
|
|
end
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
it 'transfers project to group web', :js do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit admin_project_path(project)
|
2016-12-19 06:29:58 -05:00
|
|
|
|
|
|
|
click_button 'Search for Namespace'
|
|
|
|
click_link 'group: web'
|
|
|
|
click_button 'Transfer'
|
|
|
|
|
|
|
|
expect(page).to have_content("Web / #{project.name}")
|
|
|
|
expect(page).to have_content('Namespace: Web')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'add admin himself to a project' do
|
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2016-12-19 06:29:58 -05:00
|
|
|
end
|
|
|
|
|
2017-10-03 04:35:01 -04:00
|
|
|
it 'adds admin a to a project as developer', :js do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_project_members_path(project)
|
2016-12-19 06:29:58 -05:00
|
|
|
|
|
|
|
page.within '.users-project-form' do
|
|
|
|
select2(current_user.id, from: '#user_ids', multiple: true)
|
|
|
|
select 'Developer', from: 'access_level'
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button 'Add to project'
|
|
|
|
|
|
|
|
page.within '.content-list' do
|
|
|
|
expect(page).to have_content(current_user.name)
|
|
|
|
expect(page).to have_content('Developer')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'admin remove himself from a project' do
|
|
|
|
before do
|
2018-07-11 10:36:08 -04:00
|
|
|
project.add_maintainer(user)
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_developer(current_user)
|
2016-12-19 06:29:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes admin from the project' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_project_members_path(project)
|
2016-12-19 06:29:58 -05:00
|
|
|
|
|
|
|
page.within '.content-list' do
|
|
|
|
expect(page).to have_content(current_user.name)
|
|
|
|
expect(page).to have_content('Developer')
|
|
|
|
end
|
|
|
|
|
2017-04-19 12:43:57 -04:00
|
|
|
find(:css, '.content-list li', text: current_user.name).find(:css, 'a.btn-remove').click
|
2016-12-19 06:29:58 -05:00
|
|
|
|
|
|
|
expect(page).not_to have_selector(:css, '.content-list')
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|