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

131 lines
3.5 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe "Admin::Projects" do
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)
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)
expect(page).to have_xpath("//span[@class='label label-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)
expect(page).to have_content(project.name_with_namespace)
expect(page).to have_content(project.creator.name)
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')
2017-09-10 17:25:29 +05:30
allow_any_instance_of(Projects::TransferService)
.to receive(:move_uploads_to_new_namespace).and_return(true)
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
describe 'add admin himself to a project' do
before do
2018-03-17 18:26:18 +05:30
project.add_master(user)
2017-08-17 22:00:37 +05:30
end
2018-03-17 18:26:18 +05:30
it 'adds admin a to a project as developer', :js do
2017-09-10 17:25:29 +05:30
visit project_project_members_path(project)
2017-08-17 22:00:37 +05:30
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-03-17 18:26:18 +05:30
project.add_master(user)
project.add_developer(current_user)
2017-08-17 22:00:37 +05:30
end
it 'removes admin from the project' do
2017-09-10 17:25:29 +05:30
visit project_project_members_path(project)
2017-08-17 22:00:37 +05:30
page.within '.content-list' do
expect(page).to have_content(current_user.name)
expect(page).to have_content('Developer')
end
find(:css, '.content-list li', text: current_user.name).find(:css, 'a.btn-remove').click
expect(page).not_to have_selector(:css, '.content-list')
2014-09-02 18:07:02 +05:30
end
end
end