2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe "Admin::Projects" do
|
2021-03-11 19:13:27 +05:30
|
|
|
include Spec::Support::Helpers::Features::MembersHelpers
|
2021-06-08 01:23:25 +05:30
|
|
|
include Spec::Support::Helpers::Features::InviteMembersModalHelper
|
2017-08-17 22:00:37 +05:30
|
|
|
include Select2Helper
|
|
|
|
|
|
|
|
let(:user) { create :user }
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:current_user) { create(:admin) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(current_user)
|
2021-02-22 17:27:13 +05:30
|
|
|
gitlab_enable_admin_mode_sign_in(current_user)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /admin/projects" do
|
2017-08-17 22:00:37 +05:30
|
|
|
let!(:archived_project) { create :project, :public, :archived }
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
before do
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(project).to be_persisted
|
2017-08-17 22:00:37 +05:30
|
|
|
visit admin_projects_path
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
it "is ok" do
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(current_path).to eq(admin_projects_path)
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
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
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it 'renders all projects', :js do
|
2017-08-17 22:00:37 +05:30
|
|
|
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-11-08 19:23:39 +05:30
|
|
|
expect(page).to have_xpath("//span[@class='badge badge-warning']", text: 'archived')
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
it 'renders only archived projects', :js do
|
|
|
|
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
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
describe "GET /admin/projects/:namespace_id/:id" do
|
2014-09-02 18:07:02 +05:30
|
|
|
before do
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(project).to be_persisted
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
visit admin_projects_path
|
|
|
|
click_link project.name
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
it "has project info" do
|
2017-09-10 17:25:29 +05:30
|
|
|
expect(current_path).to eq admin_project_path(project)
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content(project.path)
|
|
|
|
expect(page).to have_content(project.name)
|
2018-03-27 19:54:05 +05:30
|
|
|
expect(page).to have_content(project.full_name)
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content(project.creator.name)
|
2019-10-12 21:52:04 +05:30
|
|
|
expect(page).to have_content(project.id)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'transfer project' do
|
2017-09-10 17:25:29 +05:30
|
|
|
# The gitlab-shell transfer will fail for a project without a repository
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
before do
|
|
|
|
create(:group, name: 'Web')
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
allow_next_instance_of(Projects::TransferService) do |instance|
|
|
|
|
allow(instance).to receive(:move_uploads_to_new_namespace).and_return(true)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it 'transfers project to group web', :js do
|
2017-09-10 17:25:29 +05:30
|
|
|
visit admin_project_path(project)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
describe 'admin adds themselves to the project', :js do
|
|
|
|
before do
|
|
|
|
project.add_maintainer(user)
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
it 'adds admin to the project as developer' do
|
|
|
|
visit project_project_members_path(project)
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
invite_member(current_user.name, role: 'Developer')
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
expect(find_member_row(current_user)).to have_content('Developer')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
context 'with the invite_members_group_modal feature flag disabled' do
|
|
|
|
it 'adds admin to the project as developer' do
|
|
|
|
stub_feature_flags(invite_members_group_modal: false)
|
|
|
|
|
|
|
|
visit project_project_members_path(project)
|
|
|
|
|
|
|
|
add_member_using_form(current_user.id, role: 'Developer')
|
|
|
|
|
|
|
|
expect(find_member_row(current_user)).to have_content('Developer')
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
describe 'admin removes themselves from the project', :js do
|
2017-08-17 22:00:37 +05:30
|
|
|
before do
|
2021-04-17 20:07:23 +05:30
|
|
|
project.add_maintainer(user)
|
|
|
|
project.add_developer(current_user)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
it 'removes admin from the project' do
|
|
|
|
visit project_project_members_path(project)
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
expect(find_member_row(current_user)).to have_content('Developer')
|
2021-03-11 19:13:27 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
page.within find_member_row(current_user) do
|
|
|
|
click_button 'Leave'
|
2021-03-11 19:13:27 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
page.within('[role="dialog"]') do
|
|
|
|
click_button('Leave')
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
expect(current_path).to match dashboard_projects_path
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
|
|
|
|
# temporary method for the form until the :invite_members_group_modal feature flag is
|
|
|
|
# enabled: https://gitlab.com/gitlab-org/gitlab/-/issues/247208
|
|
|
|
def add_member_using_form(id, role: 'Developer')
|
|
|
|
page.within '.invite-users-form' do
|
|
|
|
select2(id, from: '#user_ids', multiple: true)
|
|
|
|
|
|
|
|
fill_in 'expires_at', with: 5.days.from_now.to_date
|
|
|
|
find_field('expires_at').native.send_keys :enter
|
|
|
|
|
|
|
|
select(role, from: "access_level")
|
|
|
|
|
|
|
|
click_on 'Invite'
|
|
|
|
end
|
|
|
|
end
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|