debian-mirror-gitlab/spec/features/projects_spec.rb

191 lines
5.3 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
feature 'Project' do
describe 'creating from template' do
let(:user) { create(:user) }
let(:template) { Gitlab::ProjectTemplate.find(:rails) }
before do
sign_in user
visit new_project_path
end
it "allows creation from templates" do
page.choose(template.name)
fill_in("project_path", with: template.name)
page.within '#content-body' do
click_button "Create project"
end
expect(page).to have_content template.name
end
end
2015-09-11 14:41:01 +05:30
describe 'description' do
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :repository) }
2017-09-10 17:25:29 +05:30
let(:path) { project_path(project) }
2014-09-02 18:07:02 +05:30
before do
2017-09-10 17:25:29 +05:30
sign_in(create(:admin))
2014-09-02 18:07:02 +05:30
end
2015-09-11 14:41:01 +05:30
it 'parses Markdown' do
project.update_attribute(:description, 'This is **my** project')
visit path
expect(page).to have_css('.project-home-desc > p > strong')
end
it 'passes through html-pipeline' do
project.update_attribute(:description, 'This project is the :poop:')
visit path
2017-08-17 22:00:37 +05:30
expect(page).to have_css('.project-home-desc > p > gl-emoji')
2015-09-11 14:41:01 +05:30
end
it 'sanitizes unwanted tags' do
project.update_attribute(:description, "```\ncode\n```")
visit path
expect(page).not_to have_css('.project-home-desc code')
end
it 'permits `rel` attribute on links' do
project.update_attribute(:description, 'https://google.com/')
visit path
expect(page).to have_css('.project-home-desc a[rel]')
2014-09-02 18:07:02 +05:30
end
2015-09-11 14:41:01 +05:30
end
2015-11-26 14:37:03 +05:30
describe 'remove forked relationship', js: true do
let(:user) { create(:user) }
2017-09-10 17:25:29 +05:30
let(:project) { create(:project, namespace: user.namespace) }
2015-11-26 14:37:03 +05:30
before do
2017-09-10 17:25:29 +05:30
sign_in user
2015-11-26 14:37:03 +05:30
create(:forked_project_link, forked_to_project: project)
2017-09-10 17:25:29 +05:30
visit edit_project_path(project)
2015-11-26 14:37:03 +05:30
end
2016-09-13 17:45:13 +05:30
it 'removes fork' do
2015-11-26 14:37:03 +05:30
expect(page).to have_content 'Remove fork relationship'
remove_with_confirm('Remove fork relationship', project.path)
expect(page).to have_content 'The fork relationship has been removed.'
expect(project.forked?).to be_falsey
expect(page).not_to have_content 'Remove fork relationship'
end
end
2015-09-11 14:41:01 +05:30
describe 'removal', js: true do
2017-08-17 22:00:37 +05:30
let(:user) { create(:user, username: 'test', name: 'test') }
2017-09-10 17:25:29 +05:30
let(:project) { create(:project, namespace: user.namespace, name: 'project1') }
2015-04-26 12:48:37 +05:30
2015-09-11 14:41:01 +05:30
before do
2017-09-10 17:25:29 +05:30
sign_in(user)
2015-09-11 14:41:01 +05:30
project.team << [user, :master]
2017-09-10 17:25:29 +05:30
visit edit_project_path(project)
2015-09-11 14:41:01 +05:30
end
2015-04-26 12:48:37 +05:30
2016-09-29 09:46:39 +05:30
it 'removes a project' do
2015-11-26 14:37:03 +05:30
expect { remove_with_confirm('Remove project', project.path) }.to change {Project.count}.by(-1)
2017-08-17 22:00:37 +05:30
expect(page).to have_content "Project 'test / project1' will be deleted."
2016-09-29 09:46:39 +05:30
expect(Project.all.count).to be_zero
expect(project.issues).to be_empty
expect(project.merge_requests).to be_empty
2015-04-26 12:48:37 +05:30
end
end
2016-04-02 18:10:28 +05:30
describe 'project title' do
let(:user) { create(:user) }
2017-09-10 17:25:29 +05:30
let(:project) { create(:project, namespace: user.namespace) }
2016-04-02 18:10:28 +05:30
before do
2017-09-10 17:25:29 +05:30
sign_in(user)
2016-11-03 12:29:30 +05:30
project.add_user(user, Gitlab::Access::MASTER)
2017-09-10 17:25:29 +05:30
visit project_path(project)
2016-04-02 18:10:28 +05:30
end
2016-09-13 17:45:13 +05:30
it 'clicks toggle and shows dropdown', js: true do
2016-04-02 18:10:28 +05:30
find('.js-projects-dropdown-toggle').click
2016-06-02 11:05:42 +05:30
expect(page).to have_css('.dropdown-menu-projects .dropdown-content li', count: 1)
end
end
describe 'project title' do
let(:user) { create(:user) }
2017-09-10 17:25:29 +05:30
let(:project) { create(:project, namespace: user.namespace) }
let(:project2) { create(:project, namespace: user.namespace, path: 'test') }
2016-06-02 11:05:42 +05:30
let(:issue) { create(:issue, project: project) }
context 'on issues page', js: true do
before do
2017-09-10 17:25:29 +05:30
sign_in(user)
2016-11-03 12:29:30 +05:30
project.add_user(user, Gitlab::Access::MASTER)
project2.add_user(user, Gitlab::Access::MASTER)
2017-09-10 17:25:29 +05:30
visit project_issue_path(project, issue)
2016-06-02 11:05:42 +05:30
end
2016-09-13 17:45:13 +05:30
it 'clicks toggle and shows dropdown' do
2016-06-02 11:05:42 +05:30
find('.js-projects-dropdown-toggle').click
expect(page).to have_css('.dropdown-menu-projects .dropdown-content li', count: 2)
page.within '.dropdown-menu-projects' do
click_link project.name_with_namespace
end
expect(page).to have_content project.name
end
end
end
2016-09-13 17:45:13 +05:30
describe 'tree view (default view is set to Files)' do
let(:user) { create(:user, project_view: 'files') }
let(:project) { create(:forked_project_with_submodules) }
before do
project.team << [user, :master]
2017-09-10 17:25:29 +05:30
sign_in user
visit project_path(project)
2016-09-13 17:45:13 +05:30
end
it 'has working links to files' do
click_link('PROCESS.md')
expect(page.status_code).to eq(200)
end
it 'has working links to directories' do
click_link('encoding')
expect(page.status_code).to eq(200)
end
it 'has working links to submodules' do
click_link('645f6c4c')
expect(page.status_code).to eq(200)
end
end
2017-09-10 17:25:29 +05:30
describe 'activity view' do
let(:user) { create(:user, project_view: 'activity') }
let(:project) { create(:project, :repository) }
before do
project.team << [user, :master]
sign_in user
visit project_path(project)
end
it 'loads activity', :js do
expect(page).to have_selector('.event-item')
end
end
2015-11-26 14:37:03 +05:30
def remove_with_confirm(button_text, confirm_with)
click_button button_text
fill_in 'confirm_name_input', with: confirm_with
2015-04-26 12:48:37 +05:30
click_button 'Confirm'
2014-09-02 18:07:02 +05:30
end
end