debian-mirror-gitlab/spec/features/admin/admin_projects_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

166 lines
5 KiB
Ruby
Raw Normal View History

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
2022-01-26 12:08:38 +05:30
include Spec::Support::Helpers::ModalHelpers
2017-08-17 22:00:37 +05:30
2022-08-13 15:12:31 +05:30
let_it_be_with_reload(:user) { create :user }
let_it_be_with_reload(:project) { create(:project, :with_namespace_settings) }
let_it_be_with_reload(:current_user) { create(:admin) }
2017-09-10 17:25:29 +05:30
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
2022-08-13 15:12:31 +05:30
describe 'when membership is set to expire', :js do
it 'renders relative time' do
expire_time = Time.current + 2.days
current_user.update!(time_display_relative: true)
project.add_member(user, Gitlab::Access::REPORTER, expires_at: expire_time)
visit admin_project_path(project)
expect(page).to have_content(/Expires in \d day/)
end
it 'renders absolute time' do
expire_time = Time.current.tomorrow.middle_of_day
current_user.update!(time_display_relative: false)
project.add_member(user, Gitlab::Access::REPORTER, expires_at: expire_time)
visit admin_project_path(project)
expect(page).to have_content("Expires on #{expire_time.strftime('%b %-d')}")
end
end
2014-09-02 18:07:02 +05:30
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
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(admin_projects_path, ignore_query: true)
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)
2022-01-26 12:08:38 +05:30
expect(page).to have_xpath("//span[@class='gl-badge badge badge-pill badge-warning md']", 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
2021-09-30 23:02:18 +05:30
let!(:access_request) { create(:project_member, :access_request, project: project) }
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
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path admin_project_path(project), ignore_query: true
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
2021-09-30 23:02:18 +05:30
context 'when project has open access requests' do
it 'shows access requests with link to manage access' do
page.within '[data-testid="access-requests"]' do
expect(page).to have_content access_request.user.name
expect(page).to have_link 'Manage access', href: project_project_members_path(project, tab: 'access_requests')
end
end
end
2017-08-17 22:00:37 +05:30
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
2022-07-16 23:28:13 +05:30
let(:project) { create(:project, :repository, :with_namespace_settings) }
2017-09-10 17:25:29 +05:30
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'
2021-11-18 22:05:49 +05:30
click_button 'group: web'
2017-08-17 22:00:37 +05:30
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
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
2022-01-26 12:08:38 +05:30
within_modal do
2021-04-17 20:07:23 +05:30
click_button('Leave')
2017-08-17 22:00:37 +05:30
end
2022-05-07 20:08:51 +05:30
expect(page).to have_current_path(dashboard_projects_path, ignore_query: true, url: false)
2021-06-08 01:23:25 +05:30
end
end
2014-09-02 18:07:02 +05:30
end