Commit bc841c7d authored by Robert Speicher's avatar Robert Speicher

Merge branch 'port-features-project-project-to-rspec' into 'master'

Migrate features/project/project.feature to RSpec and reorganize several Project feature specs

See merge request gitlab-org/gitlab-ce!18223
parents ffc9a470 13f7415a
Feature: Project
Background:
Given I sign in as a user
And I own project "Shop"
And project "Shop" has push event
And I visit project "Shop" page
Scenario: I edit the project avatar
Given I visit edit project "Shop" page
When I change the project avatar
And I should see new project avatar
And I should see the "Remove avatar" button
Scenario: I remove the project avatar
Given I visit edit project "Shop" page
And I have an project avatar
When I remove my project avatar
Then I should see the default project avatar
And I should not see the "Remove avatar" button
@javascript
Scenario: I should have readme on page
And I visit project "Shop" page
Then I should see project "Shop" README
Scenario: I should see last commit with CI
Given project "Shop" has CI enabled
Given project "Shop" has CI build
And I visit project "Shop" page
And I should see last commit with CI status
@javascript
Scenario: I should see project activity
When I visit project "Shop" activity page
Then I should see project "Shop" activity feed
Scenario: I visit edit project
When I visit edit project "Shop" page
Then I should see project settings
Scenario: I edit project
When I visit edit project "Shop" page
And change project settings
And I save project
Then I should see project with new settings
Scenario: I change project path
When I visit edit project "Shop" page
And change project path settings
Then I should see project with new path settings
Scenario: I should change project default branch
When I visit edit project "Shop" page
And change project default branch
And I save project
Then I should see project default branch changed
Scenario: I tag a project
When I visit edit project "Shop" page
Then I should see project settings
And I add project tags
And I save project
Then I should see project tags
Scenario: I should not see "New Issue" or "New Merge Request" buttons
Given I disable issues and merge requests in project
When I visit project "Shop" page
Then I should not see "New Issue" button
And I should not see "New Merge Request" button
Scenario: I should not see Project snippets
Given I disable snippets in project
When I visit project "Shop" page
Then I should not see "Snippets" button
@javascript
Scenario: I edit Project Notifications
Given I click notifications drop down button
When I choose Mention setting
Then I should see Notification saved message
Scenario: I should see command line instructions
Given I own an empty project
And I visit my empty project page
And I create bare repo
Then I should see command line instructions
class Spinach::Features::Project < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
include WaitForRequests
step 'change project settings' do
fill_in 'project_name_edit', with: 'NewName'
end
step 'I save project' do
page.within '.general-settings' do
click_button 'Save changes'
end
end
step 'I should see project with new settings' do
expect(find_field('project_name').value).to eq 'NewName'
end
step 'change project path settings' do
fill_in 'project_path', with: 'new-path'
click_button 'Rename'
end
step 'I should see project with new path settings' do
expect(project.path).to eq 'new-path'
end
step 'I change the project avatar' do
attach_file(
:project_avatar,
File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')
)
page.within '.general-settings' do
click_button 'Save changes'
end
@project.reload
end
step 'I should see new project avatar' do
expect(@project.avatar).to be_instance_of AvatarUploader
url = @project.avatar.url
expect(url).to eq "/uploads/-/system/project/avatar/#{@project.id}/banana_sample.gif"
end
step 'I should see the "Remove avatar" button' do
expect(page).to have_link('Remove avatar')
end
step 'I have an project avatar' do
attach_file(
:project_avatar,
File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')
)
page.within '.general-settings' do
click_button 'Save changes'
end
@project.reload
end
step 'I remove my project avatar' do
click_link 'Remove avatar'
@project.reload
end
step 'I should see the default project avatar' do
expect(@project.avatar?).to eq false
end
step 'I should not see the "Remove avatar" button' do
expect(page).not_to have_link('Remove avatar')
end
step 'change project default branch' do
select 'fix', from: 'project_default_branch'
page.within '.general-settings' do
click_button 'Save changes'
end
end
step 'I should see project default branch changed' do
expect(find(:css, 'select#project_default_branch').value).to eq 'fix'
end
step 'I select project "Forum" README tab' do
click_link 'Readme'
end
step 'I should see project "Forum" README' do
page.within('.readme-holder') do
expect(page).to have_content 'Sample repo for testing gitlab features'
end
end
step 'I should see project "Shop" README' do
wait_for_requests
page.within('.readme-holder') do
expect(page).to have_content 'testme'
end
end
step 'I add project tags' do
fill_in 'Tags', with: 'tag1, tag2'
end
step 'I should see project tags' do
expect(find_field('Tags').value).to eq 'tag1, tag2'
end
step 'I should not see "New Issue" button' do
expect(page).not_to have_link 'New Issue'
end
step 'I should not see "New Merge Request" button' do
expect(page).not_to have_link 'New Merge Request'
end
step 'I should not see "Snippets" button' do
page.within '.content' do
expect(page).not_to have_link 'Snippets'
end
end
step 'project "Shop" belongs to group' do
group = create(:group)
@project.namespace = group
@project.save!
end
step 'I click notifications drop down button' do
first('.notifications-btn').click
end
step 'I choose Mention setting' do
click_link 'On mention'
end
step 'I should see Notification saved message' do
page.within '#notifications-button' do
expect(page).to have_content 'On mention'
end
end
step 'I create bare repo' do
click_link 'Create empty repository'
end
step 'I should see command line instructions' do
page.within ".empty_wrapper" do
expect(page).to have_content("Command line instructions")
end
end
end
...@@ -25,72 +25,6 @@ module SharedProject ...@@ -25,72 +25,6 @@ module SharedProject
@project.add_master(@user) @project.add_master(@user)
end end
step 'I disable snippets in project' do
@project.snippets_enabled = false
@project.save
end
step 'I disable issues and merge requests in project' do
@project.issues_enabled = false
@project.merge_requests_enabled = false
@project.save
end
# Add another user to project "Shop"
step 'I add a user to project "Shop"' do
@project = Project.find_by(name: "Shop")
other_user = create(:user, name: 'Alpha')
@project.add_master(other_user)
end
# Create another specific project called "Forum"
step 'I own project "Forum"' do
@project = Project.find_by(name: "Forum")
@project ||= create(:project, :repository, name: "Forum", namespace: @user.namespace, path: 'forum_project')
@project.build_project_feature
@project.project_feature.save
@project.add_master(@user)
end
# Create an empty project without caring about the name
step 'I own an empty project' do
@project = create(:project, name: 'Empty Project', namespace: @user.namespace)
@project.add_master(@user)
end
step 'I visit my empty project page' do
project = Project.find_by(name: 'Empty Project')
visit project_path(project)
end
step 'I visit project "Shop" activity page' do
project = Project.find_by(name: 'Shop')
visit project_path(project)
end
step 'project "Shop" has push event' do
@project = Project.find_by(name: "Shop")
@event = create(:push_event, project: @project, author: @user)
create(:push_event_payload,
event: @event,
action: :created,
commit_to: '6d394385cf567f80a8fd85055db1ab4c5295806f',
ref: 'fix',
commit_count: 1)
end
step 'I should see project "Shop" activity feed' do
project = Project.find_by(name: "Shop")
expect(page).to have_content "#{@user.name} pushed new branch fix at #{project.full_name}"
end
step 'I should see project settings' do
expect(current_path).to eq edit_project_path(@project)
expect(page).to have_content("Project name")
expect(page).to have_content("Permissions")
end
def current_project def current_project
@project ||= Project.first @project ||= Project.first
end end
...@@ -206,24 +140,6 @@ module SharedProject ...@@ -206,24 +140,6 @@ module SharedProject
create(:label, project: project, title: 'enhancement') create(:label, project: project, title: 'enhancement')
end end
step 'project "Shop" has CI enabled' do
project = Project.find_by(name: "Shop")
project.enable_ci
end
step 'project "Shop" has CI build' do
project = Project.find_by(name: "Shop")
pipeline = create :ci_pipeline, project: project, sha: project.commit.sha, ref: 'master'
pipeline.skip
end
step 'I should see last commit with CI status' do
page.within ".blob-commit-info" do
expect(page).to have_content(project.commit.sha[0..6])
expect(page).to have_link("Commit: skipped")
end
end
step 'The project is internal' do step 'The project is internal' do
@project.update(visibility_level: Gitlab::VisibilityLevel::INTERNAL) @project.update(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
end end
......
require 'spec_helper' require 'spec_helper'
feature 'Project Activity RSS' do feature 'Project Activity RSS' do
let(:user) { create(:user) } let(:project) { create(:project, :public) }
let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } let(:user) { project.owner }
let(:path) { activity_project_path(project) } let(:path) { activity_project_path(project) }
before do before do
...@@ -11,8 +11,7 @@ feature 'Project Activity RSS' do ...@@ -11,8 +11,7 @@ feature 'Project Activity RSS' do
context 'when signed in' do context 'when signed in' do
before do before do
project.add_developer(user) sign_in(project.owner)
sign_in(user)
visit path visit path
end end
......
require 'spec_helper'
feature 'Projects > Activity > User sees activity' do
let(:project) { create(:project, :repository, :public) }
let(:user) { project.creator }
before do
event = create(:push_event, project: project, author: user)
create(:push_event_payload,
event: event,
action: :created,
commit_to: '6d394385cf567f80a8fd85055db1ab4c5295806f',
ref: 'fix',
commit_count: 1)
visit activity_project_path(project)
end
it 'shows the last push in the activity page', :js do
expect(page).to have_content "#{user.name} pushed new branch fix"
end
end
require 'rails_helper'
feature 'Project edit', :js do
let(:admin) { create(:admin) }
let(:user) { create(:user) }
let(:project) { create(:project) }
context 'feature visibility' do
before do
project.add_master(user)
sign_in(user)
visit edit_project_path(project)
end
context 'merge requests select' do
it 'hides merge requests section' do
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
expect(page).to have_selector('.merge-requests-feature', visible: false)
end
context 'given project with merge_requests_disabled access level' do
let(:project) { create(:project, :merge_requests_disabled) }
it 'hides merge requests section' do
expect(page).to have_selector('.merge-requests-feature', visible: false)
end
end
end
context 'builds select' do
it 'hides builds select section' do
find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .project-feature-toggle').click
expect(page).to have_selector('.builds-feature', visible: false)
end
context 'given project with builds_disabled access level' do
let(:project) { create(:project, :builds_disabled) }
it 'hides builds select section' do
expect(page).to have_selector('.builds-feature', visible: false)
end
end
end
end
context 'LFS enabled setting' do
before do
sign_in(admin)
end
it 'displays the correct elements' do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
visit edit_project_path(project)
expect(page).to have_content('Git Large File Storage')
expect(page).to have_selector('input[name="project[lfs_enabled]"] + button', visible: true)
end
end
end
require 'spec_helper'
feature 'user browses project', :js do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
project.add_master(user)
sign_in(user)
visit project_tree_path(project, project.default_branch)
end
scenario "can see blame of '.gitignore'" do
click_link ".gitignore"
click_link 'Blame'
expect(page).to have_content "*.rb"
expect(page).to have_content "Dmitriy Zaporozhets"
expect(page).to have_content "Initial commit"
end
scenario 'can see raw content of LFS pointer with LFS disabled' do
allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(false)
click_link 'files'
click_link 'lfs'
click_link 'lfs_object.iso'
wait_for_requests
expect(page).not_to have_content 'Download (1.5 MB)'
expect(page).to have_content 'version https://git-lfs.github.com/spec/v1'
expect(page).to have_content 'oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897'
expect(page).to have_content 'size 1575078'
end
scenario 'can see last commit for current directory' do
last_commit = project.repository.last_commit_for_path(project.default_branch, 'files')
click_link 'files'
wait_for_requests
page.within('.blob-commit-info') do
expect(page).to have_content last_commit.short_id
expect(page).to have_content last_commit.author_name
end
end
end
require 'spec_helper'
feature 'User wants to create a file' do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
background do
project.add_master(user)
sign_in user
visit project_new_blob_path(project, project.default_branch)
end
def submit_new_file(options)
file_name = find('#file_name')
file_name.set options[:file_name] || 'README.md'
file_content = find('#file-content', visible: false)
file_content.set options[:file_content] || 'Some content'
click_button 'Commit changes'
end
scenario 'file name contains Chinese characters' do
submit_new_file(file_name: '测试.md')
expect(page).to have_content 'The file has been successfully created.'
end
scenario 'directory name contains Chinese characters' do
submit_new_file(file_name: '中文/测试.md')
expect(page).to have_content 'The file has been successfully created'
end
scenario 'file name contains directory traversal' do
submit_new_file(file_name: '../README.md')
expect(page).to have_content 'Path cannot include directory traversal'
end
end
require 'spec_helper' require 'spec_helper'
require 'fileutils'
feature 'User wants to add a Dockerfile file' do describe 'Projects > Files > User wants to add a Dockerfile file' do
before do before do
user = create(:user)
project = create(:project, :repository) project = create(:project, :repository)
project.add_master(user) sign_in project.owner
sign_in user
visit project_new_blob_path(project, 'master', file_name: 'Dockerfile') visit project_new_blob_path(project, 'master', file_name: 'Dockerfile')
end end
scenario 'user can see Dockerfile dropdown' do it 'user can pick a Dockerfile file from the dropdown', :js do
expect(page).to have_css('.dockerfile-selector') expect(page).to have_css('.dockerfile-selector')
end
scenario 'user can pick a Dockerfile file from the dropdown', :js do
find('.js-dockerfile-selector').click find('.js-dockerfile-selector').click
wait_for_requests wait_for_requests
......
require 'spec_helper' require 'spec_helper'
feature 'Download buttons in files tree' do describe 'Projects > Files > Download buttons in files tree' do
given(:user) { create(:user) } let(:project) { create(:project, :repository) }
given(:role) { :developer } let(:user) { project.creator }
given(:status) { 'success' }
given(:project) { create(:project, :repository) }
given(:pipeline) do let(:pipeline) do
create(:ci_pipeline, create(:ci_pipeline,
project: project, project: project,
sha: project.commit.sha, sha: project.commit.sha,
ref: project.default_branch, ref: project.default_branch,
status: status) status: 'success')
end end
given!(:build) do let!(:build) do
create(:ci_build, :success, :artifacts, create(:ci_build, :success, :artifacts,
pipeline: pipeline, pipeline: pipeline,
status: pipeline.status, status: pipeline.status,
name: 'build') name: 'build')
end end
background do before do
sign_in(user) sign_in(user)
project.add_role(user, role) project.add_developer(user)
end
describe 'when files tree' do
context 'with artifacts' do
before do
visit project_tree_path(project, project.default_branch) visit project_tree_path(project, project.default_branch)
end end
scenario 'shows download artifacts button' do context 'with artifacts' do
it 'shows download artifacts button' do
href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build') href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build')
expect(page).to have_link "Download '#{build.name}'", href: href expect(page).to have_link "Download '#{build.name}'", href: href
end end
end end
end
end end
require 'spec_helper' require 'spec_helper'
feature 'User uses soft wrap whilst editing file', :js do describe 'Projects > Files > User uses soft wrap whilst editing file', :js do
before do before do
user = create(:user)
project = create(:project, :repository) project = create(:project, :repository)
project.add_master(user) user = project.owner
sign_in user sign_in user
visit project_new_blob_path(project, 'master', file_name: 'test_file-name') visit project_new_blob_path(project, 'master', file_name: 'test_file-name')
page.within('.file-editor.code') do page.within('.file-editor.code') do
...@@ -23,7 +22,7 @@ feature 'User uses soft wrap whilst editing file', :js do ...@@ -23,7 +22,7 @@ feature 'User uses soft wrap whilst editing file', :js do
let(:toggle_button) { find('.soft-wrap-toggle') } let(:toggle_button) { find('.soft-wrap-toggle') }
scenario 'user clicks the "Soft wrap" button and then "No wrap" button' do it 'user clicks the "Soft wrap" button and then "No wrap" button' do
wrapped_content_width = get_content_width wrapped_content_width = get_content_width
toggle_button.click toggle_button.click
expect(toggle_button).to have_content 'No wrap' expect(toggle_button).to have_content 'No wrap'
......
require 'spec_helper' require 'spec_helper'
feature 'User wants to edit a file' do describe 'Projects > Files > User wants to edit a file' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { project.owner }
let(:commit_params) do let(:commit_params) do
{ {
start_branch: project.default_branch, start_branch: project.default_branch,
...@@ -15,14 +15,13 @@ feature 'User wants to edit a file' do ...@@ -15,14 +15,13 @@ feature 'User wants to edit a file' do
} }
end end
background do before do
project.add_master(user)
sign_in user sign_in user
visit project_edit_blob_path(project, visit project_edit_blob_path(project,
File.join(project.default_branch, '.gitignore')) File.join(project.default_branch, '.gitignore'))
end end
scenario 'file has been updated since the user opened the edit page' do it 'file has been updated since the user opened the edit page' do
Files::UpdateService.new(project, user, commit_params).execute Files::UpdateService.new(project, user, commit_params).execute
click_button 'Commit changes' click_button 'Commit changes'
......
require 'spec_helper' require 'spec_helper'
feature 'User views files page' do describe 'Projects > Files > User views files page' do
let(:user) { create(:user) }
let(:project) { create(:forked_project_with_submodules) } let(:project) { create(:forked_project_with_submodules) }
let(:user) { project.owner }
before do before do
project.add_master(user)
sign_in user sign_in user
visit project_tree_path(project, project.repository.root_ref) visit project_tree_path(project, project.repository.root_ref)
end end
scenario 'user sees folders and submodules sorted together, followed by files' do it 'user sees folders and submodules sorted together, followed by files' do
rows = all('td.tree-item-file-name').map(&:text) rows = all('td.tree-item-file-name').map(&:text)
tree = project.repository.tree tree = project.repository.tree
......
require 'spec_helper' require 'spec_helper'
feature 'Find file keyboard shortcuts', :js do describe 'Projects > Files > Find file keyboard shortcuts', :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { project.owner }
before do before do
project.add_master(user)
sign_in user sign_in user
visit project_find_file_path(project, project.repository.root_ref) visit project_find_file_path(project, project.repository.root_ref)
......
require 'spec_helper' require 'spec_helper'
feature 'User wants to add a .gitignore file' do describe 'Projects > Files > User wants to add a .gitignore file' do
before do before do
user = create(:user)
project = create(:project, :repository) project = create(:project, :repository)
project.add_master(user) sign_in project.owner
sign_in user
visit project_new_blob_path(project, 'master', file_name: '.gitignore') visit project_new_blob_path(project, 'master', file_name: '.gitignore')
end end
scenario 'user can see .gitignore dropdown' do it 'user can pick a .gitignore file from the dropdown', :js do
expect(page).to have_css('.gitignore-selector') expect(page).to have_css('.gitignore-selector')
end
scenario 'user can pick a .gitignore file from the dropdown', :js do
find('.js-gitignore-selector').click find('.js-gitignore-selector').click
wait_for_requests wait_for_requests
within '.gitignore-selector' do within '.gitignore-selector' do
find('.dropdown-input-field').set('rails') find('.dropdown-input-field').set('rails')
find('.dropdown-content li', text: 'Rails').click find('.dropdown-content li', text: 'Rails').click
end end
wait_for_requests wait_for_requests
expect(page).to have_css('.gitignore-selector .dropdown-toggle-text', text: 'Rails') expect(page).to have_css('.gitignore-selector .dropdown-toggle-text', text: 'Rails')
......
require 'spec_helper' require 'spec_helper'
feature 'User wants to add a .gitlab-ci.yml file' do describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do
before do before do
user = create(:user)
project = create(:project, :repository) project = create(:project, :repository)
project.add_master(user) sign_in project.owner
sign_in user
visit project_new_blob_path(project, 'master', file_name: '.gitlab-ci.yml') visit project_new_blob_path(project, 'master', file_name: '.gitlab-ci.yml')
end end
scenario 'user can see .gitlab-ci.yml dropdown' do it 'user can pick a template from the dropdown', :js do
expect(page).to have_css('.gitlab-ci-yml-selector') expect(page).to have_css('.gitlab-ci-yml-selector')
end
scenario 'user can pick a template from the dropdown', :js do
find('.js-gitlab-ci-yml-selector').click find('.js-gitlab-ci-yml-selector').click
wait_for_requests wait_for_requests
within '.gitlab-ci-yml-selector' do within '.gitlab-ci-yml-selector' do
find('.dropdown-input-field').set('Jekyll') find('.dropdown-input-field').set('Jekyll')
find('.dropdown-content li', text: 'Jekyll').click find('.dropdown-content li', text: 'Jekyll').click
end end
wait_for_requests wait_for_requests
expect(page).to have_css('.gitlab-ci-yml-selector .dropdown-toggle-text', text: 'Jekyll') expect(page).to have_css('.gitlab-ci-yml-selector .dropdown-toggle-text', text: 'Jekyll')
......
require 'spec_helper' require 'spec_helper'
feature 'project owner creates a license file', :js do describe 'Projects > Files > Project owner creates a license file', :js do
let(:project_master) { create(:user) }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
background do let(:project_master) { project.owner }
before do
project.repository.delete_file(project_master, 'LICENSE', project.repository.delete_file(project_master, 'LICENSE',
message: 'Remove LICENSE', branch_name: 'master') message: 'Remove LICENSE', branch_name: 'master')
project.add_master(project_master)
sign_in(project_master) sign_in(project_master)
visit project_path(project) visit project_path(project)
end end
scenario 'project master creates a license file manually from a template' do it 'project master creates a license file manually from a template' do
visit project_tree_path(project, project.repository.root_ref) visit project_tree_path(project, project.repository.root_ref)
find('.add-to-tree').click find('.add-to-tree').click
click_link 'New file' click_link 'New file'
...@@ -35,7 +35,7 @@ feature 'project owner creates a license file', :js do ...@@ -35,7 +35,7 @@ feature 'project owner creates a license file', :js do
expect(page).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}") expect(page).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}")
end end
scenario 'project master creates a license file from the "Add license" link' do it 'project master creates a license file from the "Add license" link' do
click_link 'Add License' click_link 'Add License'
expect(page).to have_content('New file') expect(page).to have_content('New file')
......
require 'spec_helper' require 'spec_helper'
feature 'project owner sees a link to create a license file in empty project', :js do describe 'Projects > Files > Project owner sees a link to create a license file in empty project', :js do
let(:project_master) { create(:user) }
let(:project) { create(:project_empty_repo) } let(:project) { create(:project_empty_repo) }
let(:project_master) { project.owner }
background do before do
project.add_master(project_master)
sign_in(project_master) sign_in(project_master)
end end
scenario 'project master creates a license file from a template' do it 'project master creates a license file from a template' do
visit project_path(project) visit project_path(project)
click_on 'Add License' click_on 'Add License'
expect(page).to have_content('New file') expect(page).to have_content('New file')
......
require 'spec_helper' require 'spec_helper'
feature 'Template type dropdown selector', :js do describe 'Projects > Files > Template type dropdown selector', :js do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { project.owner }
before do before do
project.add_master(user)
sign_in user sign_in user
end end
...@@ -14,16 +13,16 @@ feature 'Template type dropdown selector', :js do ...@@ -14,16 +13,16 @@ feature 'Template type dropdown selector', :js do
create_and_edit_file('.random-file.js') create_and_edit_file('.random-file.js')
end end
scenario 'not displayed' do it 'not displayed' do
check_type_selector_display(false) check_type_selector_display(false)
end end
scenario 'selects every template type correctly' do it 'selects every template type correctly' do
fill_in 'file_path', with: '.gitignore' fill_in 'file_path', with: '.gitignore'
try_selecting_all_types try_selecting_all_types
end end
scenario 'updates toggle value when input matches' do it 'updates toggle value when input matches' do
fill_in 'file_path', with: '.gitignore' fill_in 'file_path', with: '.gitignore'
check_type_selector_toggle_text('.gitignore') check_type_selector_toggle_text('.gitignore')
end end
...@@ -34,15 +33,15 @@ feature 'Template type dropdown selector', :js do ...@@ -34,15 +33,15 @@ feature 'Template type dropdown selector', :js do
visit project_edit_blob_path(project, File.join(project.default_branch, 'LICENSE')) visit project_edit_blob_path(project, File.join(project.default_branch, 'LICENSE'))
end end
scenario 'displayed' do it 'displayed' do
check_type_selector_display(true) check_type_selector_display(true)
end end
scenario 'is displayed when input matches' do it 'is displayed when input matches' do
check_type_selector_display(true) check_type_selector_display(true)
end end
scenario 'selects every template type correctly' do it 'selects every template type correctly' do
try_selecting_all_types try_selecting_all_types
end end
...@@ -51,7 +50,7 @@ feature 'Template type dropdown selector', :js do ...@@ -51,7 +50,7 @@ feature 'Template type dropdown selector', :js do
click_link 'Preview changes' click_link 'Preview changes'
end end
scenario 'type selector is hidden and shown correctly' do it 'type selector is hidden and shown correctly' do
check_type_selector_display(false) check_type_selector_display(false)
click_link 'Write' click_link 'Write'
check_type_selector_display(true) check_type_selector_display(true)
...@@ -64,15 +63,15 @@ feature 'Template type dropdown selector', :js do ...@@ -64,15 +63,15 @@ feature 'Template type dropdown selector', :js do
visit project_new_blob_path(project, 'master', file_name: '.gitignore') visit project_new_blob_path(project, 'master', file_name: '.gitignore')
end end
scenario 'is displayed' do it 'is displayed' do
check_type_selector_display(true) check_type_selector_display(true)
end end
scenario 'toggle is set to the correct value' do it 'toggle is set to the correct value' do
check_type_selector_toggle_text('.gitignore') check_type_selector_toggle_text('.gitignore')
end end
scenario 'selects every template type correctly' do it 'selects every template type correctly' do
try_selecting_all_types try_selecting_all_types
end end
end end
...@@ -82,15 +81,15 @@ feature 'Template type dropdown selector', :js do ...@@ -82,15 +81,15 @@ feature 'Template type dropdown selector', :js do
visit project_new_blob_path(project, project.default_branch) visit project_new_blob_path(project, project.default_branch)
end end
scenario 'type selector is shown' do it 'type selector is shown' do
check_type_selector_display(true) check_type_selector_display(true)
end end
scenario 'toggle is set to the proper value' do it 'toggle is set to the proper value' do
check_type_selector_toggle_text('Choose type') check_type_selector_toggle_text('Choose type')
end end
scenario 'selects every template type correctly' do it 'selects every template type correctly' do
try_selecting_all_types try_selecting_all_types
end end
end end
......
require 'spec_helper' require 'spec_helper'
feature 'Template Undo Button', :js do describe 'Projects > Files > Template Undo Button', :js do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { project.owner }
before do before do
project.add_master(user)
sign_in user sign_in user
end end
...@@ -15,7 +14,7 @@ feature 'Template Undo Button', :js do ...@@ -15,7 +14,7 @@ feature 'Template Undo Button', :js do
select_file_template('.js-license-selector', 'Apache License 2.0') select_file_template('.js-license-selector', 'Apache License 2.0')
end end
scenario 'reverts template application' do it 'reverts template application' do
try_template_undo('http://www.apache.org/licenses/', 'Apply a license template') try_template_undo('http://www.apache.org/licenses/', 'Apply a license template')
end end
end end
...@@ -27,7 +26,7 @@ feature 'Template Undo Button', :js do ...@@ -27,7 +26,7 @@ feature 'Template Undo Button', :js do
select_file_template('.js-license-selector', 'Apache License 2.0') select_file_template('.js-license-selector', 'Apache License 2.0')
end end
scenario 'reverts template application' do it 'reverts template application' do
try_template_undo('http://www.apache.org/licenses/', 'Apply a license template') try_template_undo('http://www.apache.org/licenses/', 'Apply a license template')
end end
end end
......
require 'spec_helper' require 'spec_helper'
# This is a regression test for https://gitlab.com/gitlab-org/gitlab-ce/issues/37569 # This is a regression test for https://gitlab.com/gitlab-org/gitlab-ce/issues/37569
describe 'User browses a tree with a folder containing only a folder' do describe 'Projects > Files > User browses a tree with a folder containing only a folder' do
let(:project) { create(:project, :empty_repo) } let(:project) { create(:project, :empty_repo) }
let(:user) { project.creator } let(:user) { project.owner }
before do before do
# We need to disable the tree.flat_path provided by Gitaly to reproduce the issue # We need to disable the tree.flat_path provided by Gitaly to reproduce the issue
......
require 'spec_helper' require 'spec_helper'
describe 'User browses files' do describe 'Projects > Files > User browses files' do
include DropzoneHelper
let(:fork_message) do let(:fork_message) do
"You're not allowed to make changes to this project directly. "\ "You're not allowed to make changes to this project directly. "\
"A fork of this project has been created that you can make changes in, so you can submit a merge request." "A fork of this project has been created that you can make changes in, so you can submit a merge request."
...@@ -12,13 +10,24 @@ describe 'User browses files' do ...@@ -12,13 +10,24 @@ describe 'User browses files' do
let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) } let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) }
let(:tree_path_ref_6d39438) { project_tree_path(project, '6d39438') } let(:tree_path_ref_6d39438) { project_tree_path(project, '6d39438') }
let(:tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) } let(:tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) }
let(:user) { create(:user) } let(:user) { project.owner }
before do before do
project.add_master(user)
sign_in(user) sign_in(user)
end end
it 'shows last commit for current directory' do
visit(tree_path_root_ref)
click_link 'files'
last_commit = project.repository.last_commit_for_path(project.default_branch, 'files')
page.within('.blob-commit-info') do
expect(page).to have_content last_commit.short_id
expect(page).to have_content last_commit.author_name
end
end
context 'when browsing the master branch' do context 'when browsing the master branch' do
before do before do
visit(tree_path_root_ref) visit(tree_path_root_ref)
...@@ -48,7 +57,7 @@ describe 'User browses files' do ...@@ -48,7 +57,7 @@ describe 'User browses files' do
expect(page).not_to have_link('Browse Files') expect(page).not_to have_link('Browse Files')
end end
it 'shows the "Browse Code" link' do it 'shows the "Browse Files" link' do
click_link('History') click_link('History')
expect(page).to have_link('Browse Files') expect(page).to have_link('Browse Files')
...@@ -121,6 +130,14 @@ describe 'User browses files' do ...@@ -121,6 +130,14 @@ describe 'User browses files' do
wait_for_requests wait_for_requests
expect(page).to have_content('*.rbc') expect(page).to have_content('*.rbc')
end end
it 'is possible to blame' do
click_link 'Blame'
expect(page).to have_content "*.rb"
expect(page).to have_content "Dmitriy Zaporozhets"
expect(page).to have_content "Initial commit"
end
end end
context 'when browsing a raw file' do context 'when browsing a raw file' do
...@@ -133,57 +150,4 @@ describe 'User browses files' do ...@@ -133,57 +150,4 @@ describe 'User browses files' do
expect(source).to eq('') # Body is filled in by gitlab-workhorse expect(source).to eq('') # Body is filled in by gitlab-workhorse
end end
end end
context 'when browsing an LFS object' do
before do
allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(true)
visit(project_tree_path(project, 'lfs'))
end
it 'shows an LFS object' do
click_link('files')
click_link('lfs')
click_link('lfs_object.iso')
expect(page).to have_content('Download (1.5 MB)')
expect(page).not_to have_content('version https://git-lfs.github.com/spec/v1')
expect(page).not_to have_content('oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897')
expect(page).not_to have_content('size 1575078')
page.within('.content') do
expect(page).to have_content('Delete')
expect(page).to have_content('History')
expect(page).to have_content('Permalink')
expect(page).to have_content('Replace')
expect(page).not_to have_content('Annotate')
expect(page).not_to have_content('Blame')
expect(page).not_to have_content('Edit')
expect(page).to have_link('Download')
end
end
end
context 'when previewing a file content' do
before do
visit(tree_path_root_ref)
end
it 'shows a preview of a file content', :js do
find('.add-to-tree').click
click_link('Upload file')
drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'logo_sample.svg'))
page.within('#modal-upload-blob') do
fill_in(:commit_message, with: 'New commit message')
fill_in(:branch_name, with: 'new_branch_name', visible: true)
click_button('Upload file')
end
wait_for_all_requests
visit(project_blob_path(project, 'new_branch_name/logo_sample.svg'))
expect(page).to have_css('.file-content img')
end
end
end end
require 'spec_helper'
describe 'Projects > Files > User browses LFS files' do
let(:project) { create(:project, :repository) }
let(:user) { project.owner }
before do
sign_in(user)
end
context 'when LFS is disabled', :js do
before do
allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(false)
visit project_tree_path(project, 'lfs')
end
it 'is possible to see raw content of LFS pointer' do
click_link 'files'
click_link 'lfs'
click_link 'lfs_object.iso'
expect(page).to have_content 'version https://git-lfs.github.com/spec/v1'
expect(page).to have_content 'oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897'
expect(page).to have_content 'size 1575078'
expect(page).not_to have_content 'Download (1.5 MB)'
end
end
context 'when LFS is enabled' do
before do
allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(true)
visit project_tree_path(project, 'lfs')
end
it 'shows an LFS object' do
click_link('files')
click_link('lfs')
click_link('lfs_object.iso')
expect(page).to have_content('Download (1.5 MB)')
expect(page).not_to have_content('version https://git-lfs.github.com/spec/v1')
expect(page).not_to have_content('oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897')
expect(page).not_to have_content('size 1575078')
page.within('.content') do
expect(page).to have_content('Delete')
expect(page).to have_content('History')
expect(page).to have_content('Permalink')
expect(page).to have_content('Replace')
expect(page).not_to have_content('Annotate')
expect(page).not_to have_content('Blame')
expect(page).not_to have_content('Edit')
expect(page).to have_link('Download')
end
end
end
end
require 'spec_helper' require 'spec_helper'
feature 'User creates a directory', :js do describe 'Projects > Files > User creates a directory', :js do
let(:fork_message) do let(:fork_message) do
"You're not allowed to make changes to this project directly. "\ "You're not allowed to make changes to this project directly. "\
"A fork of this project has been created that you can make changes in, so you can submit a merge request." "A fork of this project has been created that you can make changes in, so you can submit a merge request."
......
require 'spec_helper' require 'spec_helper'
describe 'User creates files' do describe 'Projects > Files > User creates files' do
let(:fork_message) do let(:fork_message) do
"You're not allowed to make changes to this project directly. "\ "You're not allowed to make changes to this project directly. "\
"A fork of this project has been created that you can make changes in, so you can submit a merge request." "A fork of this project has been created that you can make changes in, so you can submit a merge request."
...@@ -59,6 +59,31 @@ describe 'User creates files' do ...@@ -59,6 +59,31 @@ describe 'User creates files' do
expect(page).to have_selector('.file-editor') expect(page).to have_selector('.file-editor')
end end
def submit_new_file(options)
file_name = find('#file_name')
file_name.set options[:file_name] || 'README.md'
file_content = find('#file-content', visible: false)
file_content.set options[:file_content] || 'Some content'
click_button 'Commit changes'
end
it 'allows Chinese characters in file name' do
submit_new_file(file_name: '测试.md')
expect(page).to have_content 'The file has been successfully created.'
end
it 'allows Chinese characters in directory name' do
submit_new_file(file_name: '中文/测试.md')
expect(page).to have_content 'The file has been successfully created'
end
it 'does not allow directory traversal in file name' do
submit_new_file(file_name: '../README.md')
expect(page).to have_content 'Path cannot include directory traversal'
end
it 'creates and commit a new file', :js do it 'creates and commit a new file', :js do
find('#editor') find('#editor')
execute_script("ace.edit('editor').setValue('*.rbca')") execute_script("ace.edit('editor').setValue('*.rbca')")
......
require 'spec_helper' require 'spec_helper'
describe 'User deletes files' do describe 'Projects > Files > User deletes files' do
let(:fork_message) do let(:fork_message) do
"You're not allowed to make changes to this project directly. "\ "You're not allowed to make changes to this project directly. "\
"A fork of this project has been created that you can make changes in, so you can submit a merge request." "A fork of this project has been created that you can make changes in, so you can submit a merge request."
......
require 'spec_helper' require 'spec_helper'
describe 'User edits files' do describe 'Projects > Files > User edits files' do
include ProjectForksHelper include ProjectForksHelper
let(:project) { create(:project, :repository, name: 'Shop') } let(:project) { create(:project, :repository, name: 'Shop') }
let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') }
......
require 'spec_helper' require 'spec_helper'
describe 'User replaces files' do describe 'Projects > Files > User replaces files' do
include DropzoneHelper include DropzoneHelper
let(:fork_message) do let(:fork_message) do
......
require 'spec_helper' require 'spec_helper'
describe 'User searches for files' do describe 'Projects > Files > User searches for files' do
let(:user) { create(:user) } let(:user) { project.owner }
let(:project) { create(:project, :repository) }
before do before do
sign_in(user) sign_in(user)
...@@ -10,11 +9,10 @@ describe 'User searches for files' do ...@@ -10,11 +9,10 @@ describe 'User searches for files' do
describe 'project main screen' do describe 'project main screen' do
context 'when project is empty' do context 'when project is empty' do
let(:empty_project) { create(:project) } let(:project) { create(:project) }
before do before do
empty_project.add_developer(user) visit project_path(project)
visit project_path(empty_project)
end end
it 'does not show any result' do it 'does not show any result' do
...@@ -26,6 +24,8 @@ describe 'User searches for files' do ...@@ -26,6 +24,8 @@ describe 'User searches for files' do
end end
context 'when project is not empty' do context 'when project is not empty' do
let(:project) { create(:project, :repository) }
before do before do
project.add_developer(user) project.add_developer(user)
visit project_path(project) visit project_path(project)
...@@ -38,16 +38,16 @@ describe 'User searches for files' do ...@@ -38,16 +38,16 @@ describe 'User searches for files' do
end end
describe 'project tree screen' do describe 'project tree screen' do
let(:project) { create(:project, :repository) }
before do before do
project.add_developer(user) project.add_developer(user)
visit project_tree_path(project, project.default_branch) visit project_tree_path(project, project.default_branch)
end end
it 'shows "Find file" button' do it 'shows found files' do
expect(page).to have_selector('.tree-controls .shortcuts-find-file') expect(page).to have_selector('.tree-controls .shortcuts-find-file')
end
it 'shows found files' do
fill_in('search', with: 'coffee') fill_in('search', with: 'coffee')
click_button('Go') click_button('Go')
......
require 'spec_helper' require 'spec_helper'
describe 'User uploads files' do describe 'Projects > Files > User uploads files' do
include DropzoneHelper include DropzoneHelper
let(:fork_message) do let(:fork_message) do
...@@ -11,7 +11,7 @@ describe 'User uploads files' do ...@@ -11,7 +11,7 @@ describe 'User uploads files' do
let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') }
let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) } let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) }
let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) } let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) }
let(:user) { create(:user) } let(:user) { project.creator }
before do before do
project.add_master(user) project.add_master(user)
...@@ -23,7 +23,7 @@ describe 'User uploads files' do ...@@ -23,7 +23,7 @@ describe 'User uploads files' do
visit(project_tree_path_root_ref) visit(project_tree_path_root_ref)
end end
it 'uploads and commit a new file', :js do it 'uploads and commit a new text file', :js do
find('.add-to-tree').click find('.add-to-tree').click
click_link('Upload file') click_link('Upload file')
drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt')) drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
...@@ -46,6 +46,24 @@ describe 'User uploads files' do ...@@ -46,6 +46,24 @@ describe 'User uploads files' do
expect(page).to have_content('Lorem ipsum dolor sit amet') expect(page).to have_content('Lorem ipsum dolor sit amet')
expect(page).to have_content('Sed ut perspiciatis unde omnis') expect(page).to have_content('Sed ut perspiciatis unde omnis')
end end
it 'uploads and commit a new image file', :js do
find('.add-to-tree').click
click_link('Upload file')
drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'logo_sample.svg'))
page.within('#modal-upload-blob') do
fill_in(:commit_message, with: 'New commit message')
fill_in(:branch_name, with: 'new_branch_name', visible: true)
click_button('Upload file')
end
wait_for_all_requests
visit(project_blob_path(project, 'new_branch_name/logo_sample.svg'))
expect(page).to have_css('.file-content img')
end
end end
context 'when an user does not have write access' do context 'when an user does not have write access' do
......
require 'spec_helper'
describe 'Guest navigation menu' do
let(:project) { create(:project, :private, public_builds: false) }
let(:guest) { create(:user) }
before do
project.add_guest(guest)
sign_in(guest)
end
it 'shows allowed tabs only' do
visit project_path(project)
within('.nav-sidebar') do
expect(page).to have_content 'Overview'
expect(page).to have_content 'Issues'
expect(page).to have_content 'Wiki'
expect(page).not_to have_content 'Repository'
expect(page).not_to have_content 'Pipelines'
expect(page).not_to have_content 'Merge Requests'
end
end
it 'does not show fork button' do
visit project_path(project)
within('.count-buttons') do
expect(page).not_to have_link 'Fork'
end
end
it 'does not show clone path' do
visit project_path(project)
within('.project-repo-buttons') do
expect(page).not_to have_selector '.project-clone-holder'
end
end
describe 'project landing page' do
before do
project.project_feature.update!(
issues_access_level: ProjectFeature::DISABLED,
wiki_access_level: ProjectFeature::DISABLED
)
end
it 'does not show the project file list landing page' do
visit project_path(project)
expect(page).not_to have_selector '.project-stats'
expect(page).not_to have_selector '.project-last-commit'
expect(page).not_to have_selector '.project-show-files'
expect(page).to have_selector '.project-show-customize_workflow'
end
it 'shows the customize workflow when issues and wiki are disabled' do
visit project_path(project)
expect(page).to have_selector '.project-show-customize_workflow'
end
it 'shows the wiki when enabled' do
project.project_feature.update!(wiki_access_level: ProjectFeature::PRIVATE)
visit project_path(project)
expect(page).to have_selector '.project-show-wiki'
end
it 'shows the issues when enabled' do
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
visit project_path(project)
expect(page).to have_selector '.issues-list'
end
end
end
require 'spec_helper'
describe 'Edit Project Settings' do
include Select2Helper
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace, path: 'gitlab', name: 'sample') }
before do
sign_in(user)
end
describe 'Project settings section', :js do
it 'shows errors for invalid project name' do
visit edit_project_path(project)
fill_in 'project_name_edit', with: 'foo&bar'
page.within('.general-settings') do
click_button 'Save changes'
end
expect(page).to have_field 'project_name_edit', with: 'foo&bar'
expect(page).to have_content "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'."
expect(page).to have_button 'Save changes'
end
it 'shows a successful notice when the project is updated' do
visit edit_project_path(project)
fill_in 'project_name_edit', with: 'hello world'
page.within('.general-settings') do
click_button 'Save changes'
end
expect(page).to have_content "Project 'hello world' was successfully updated."
end
end
describe 'Merge request settings section' do
it 'shows "Merge commit" strategy' do
visit edit_project_path(project)
page.within '.merge-requests-feature' do
expect(page).to have_content 'Merge commit'
end
end
it 'shows "Merge commit with semi-linear history " strategy' do
visit edit_project_path(project)
page.within '.merge-requests-feature' do
expect(page).to have_content 'Merge commit with semi-linear history'
end
end
it 'shows "Fast-forward merge" strategy' do
visit edit_project_path(project)
page.within '.merge-requests-feature' do
expect(page).to have_content 'Fast-forward merge'
end
end
end
describe 'Rename repository section' do
context 'with invalid characters' do
it 'shows errors for invalid project path/name' do
rename_project(project, name: 'foo&bar', path: 'foo&bar')
expect(page).to have_field 'Project name', with: 'foo&bar'
expect(page).to have_field 'Path', with: 'foo&bar'
expect(page).to have_content "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'."
expect(page).to have_content "Path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'"
end
end
context 'when changing project name' do
it 'renames the repository' do
rename_project(project, name: 'bar')
expect(find('.breadcrumbs')).to have_content(project.name)
end
context 'with emojis' do
it 'shows error for invalid project name' do
rename_project(project, name: '🚀 foo bar ☁️')
expect(page).to have_field 'Project name', with: '🚀 foo bar ☁️'
expect(page).not_to have_content "Name can contain only letters, digits, emojis '_', '.', dash and space. It must start with letter, digit, emoji or '_'."
end
end
end
context 'when changing project path' do
let(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') }
before(:context) do
TestEnv.clean_test_path
end
after do
TestEnv.clean_test_path
end
specify 'the project is accessible via the new path' do
rename_project(project, path: 'bar')
new_path = namespace_project_path(project.namespace, 'bar')
visit new_path
expect(current_path).to eq(new_path)
expect(find('.breadcrumbs')).to have_content(project.name)
end
specify 'the project is accessible via a redirect from the old path' do
old_path = project_path(project)
rename_project(project, path: 'bar')
new_path = namespace_project_path(project.namespace, 'bar')
visit old_path
expect(current_path).to eq(new_path)
expect(find('.breadcrumbs')).to have_content(project.name)
end
context 'and a new project is added with the same path' do
it 'overrides the redirect' do
old_path = project_path(project)
rename_project(project, path: 'bar')
new_project = create(:project, namespace: user.namespace, path: 'gitlabhq', name: 'quz')
visit old_path
expect(current_path).to eq(old_path)
expect(find('.breadcrumbs')).to have_content(new_project.name)
end
end
end
end
describe 'Transfer project section', :js do
let!(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') }
let!(:group) { create(:group) }
before(:context) do
TestEnv.clean_test_path
end
before do
group.add_owner(user)
end
after do
TestEnv.clean_test_path
end
specify 'the project is accessible via the new path' do
transfer_project(project, group)
new_path = namespace_project_path(group, project)
visit new_path
wait_for_requests
expect(current_path).to eq(new_path)
expect(find('.breadcrumbs')).to have_content(project.name)
end
specify 'the project is accessible via a redirect from the old path' do
old_path = project_path(project)
transfer_project(project, group)
new_path = namespace_project_path(group, project)
visit old_path
wait_for_requests
expect(current_path).to eq(new_path)
expect(find('.breadcrumbs')).to have_content(project.name)
end
context 'and a new project is added with the same path' do
it 'overrides the redirect' do
old_path = project_path(project)
transfer_project(project, group)
new_project = create(:project, namespace: user.namespace, path: 'gitlabhq', name: 'quz')
visit old_path
expect(current_path).to eq(old_path)
expect(find('.breadcrumbs')).to have_content(new_project.name)
end
end
end
end
def rename_project(project, name: nil, path: nil)
visit edit_project_path(project)
fill_in('project_name', with: name) if name
fill_in('Path', with: path) if path
click_button('Rename project')
wait_for_edit_project_page_reload
project.reload
end
def transfer_project(project, namespace)
visit edit_project_path(project)
select2(namespace.id, from: '#new_namespace_id')
click_button('Transfer project')
confirm_transfer_modal
wait_for_edit_project_page_reload
project.reload
end
def confirm_transfer_modal
fill_in('confirm_name_input', with: project.path)
click_button 'Confirm'
end
def wait_for_edit_project_page_reload
expect(find('.project-edit-container')).to have_content('Rename repository')
end
require 'spec_helper' require 'spec_helper'
feature 'Settings for a forked project', :js do describe 'Projects > Settings > For a forked project', :js do
include ProjectForksHelper include ProjectForksHelper
let(:user) { create(:user) } let(:user) { create(:user) }
let(:original_project) { create(:project) } let(:original_project) { create(:project) }
......
require 'spec_helper' require 'spec_helper'
feature 'Integration settings' do describe 'Projects > Settings > Integration settings' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:role) { :developer } let(:role) { :developer }
let(:integrations_path) { project_settings_integrations_path(project) } let(:integrations_path) { project_settings_integrations_path(project) }
background do before do
sign_in(user) sign_in(user)
project.add_role(user, role) project.add_role(user, role)
end end
context 'for developer' do context 'for developer' do
given(:role) { :developer } let(:role) { :developer }
scenario 'to be disallowed to view' do it 'to be disallowed to view' do
visit integrations_path visit integrations_path
expect(page.status_code).to eq(404) expect(page.status_code).to eq(404)
...@@ -22,13 +22,13 @@ feature 'Integration settings' do ...@@ -22,13 +22,13 @@ feature 'Integration settings' do
end end
context 'for master' do context 'for master' do
given(:role) { :master } let(:role) { :master }
context 'Webhooks' do context 'Webhooks' do
let(:hook) { create(:project_hook, :all_events_enabled, enable_ssl_verification: true, project: project) } let(:hook) { create(:project_hook, :all_events_enabled, enable_ssl_verification: true, project: project) }
let(:url) { generate(:url) } let(:url) { generate(:url) }
scenario 'show list of webhooks' do it 'show list of webhooks' do
hook hook
visit integrations_path visit integrations_path
...@@ -46,7 +46,7 @@ feature 'Integration settings' do ...@@ -46,7 +46,7 @@ feature 'Integration settings' do
expect(page).to have_content('Wiki page events') expect(page).to have_content('Wiki page events')
end end
scenario 'create webhook' do it 'create webhook' do
visit integrations_path visit integrations_path
fill_in 'hook_url', with: url fill_in 'hook_url', with: url
...@@ -63,7 +63,7 @@ feature 'Integration settings' do ...@@ -63,7 +63,7 @@ feature 'Integration settings' do
expect(page).to have_content('Job events') expect(page).to have_content('Job events')
end end
scenario 'edit existing webhook' do it 'edit existing webhook' do
hook hook
visit integrations_path visit integrations_path
...@@ -76,7 +76,7 @@ feature 'Integration settings' do ...@@ -76,7 +76,7 @@ feature 'Integration settings' do
expect(page).to have_content(url) expect(page).to have_content(url)
end end
scenario 'test existing webhook', :js do it 'test existing webhook', :js do
WebMock.stub_request(:post, hook.url) WebMock.stub_request(:post, hook.url)
visit integrations_path visit integrations_path
...@@ -87,14 +87,14 @@ feature 'Integration settings' do ...@@ -87,14 +87,14 @@ feature 'Integration settings' do
end end
context 'remove existing webhook' do context 'remove existing webhook' do
scenario 'from webhooks list page' do it 'from webhooks list page' do
hook hook
visit integrations_path visit integrations_path
expect { click_link 'Remove' }.to change(ProjectHook, :count).by(-1) expect { click_link 'Remove' }.to change(ProjectHook, :count).by(-1)
end end
scenario 'from webhook edit page' do it 'from webhook edit page' do
hook hook
visit integrations_path visit integrations_path
click_link 'Edit' click_link 'Edit'
...@@ -108,7 +108,7 @@ feature 'Integration settings' do ...@@ -108,7 +108,7 @@ feature 'Integration settings' do
let(:hook) { create(:project_hook, project: project) } let(:hook) { create(:project_hook, project: project) }
let(:hook_log) { create(:web_hook_log, web_hook: hook, internal_error_message: 'some error') } let(:hook_log) { create(:web_hook_log, web_hook: hook, internal_error_message: 'some error') }
scenario 'show list of hook logs' do it 'show list of hook logs' do
hook_log hook_log
visit edit_project_hook_path(project, hook) visit edit_project_hook_path(project, hook)
...@@ -116,7 +116,7 @@ feature 'Integration settings' do ...@@ -116,7 +116,7 @@ feature 'Integration settings' do
expect(page).to have_content(hook_log.url) expect(page).to have_content(hook_log.url)
end end
scenario 'show hook log details' do it 'show hook log details' do
hook_log hook_log
visit edit_project_hook_path(project, hook) visit edit_project_hook_path(project, hook)
click_link 'View details' click_link 'View details'
...@@ -126,7 +126,7 @@ feature 'Integration settings' do ...@@ -126,7 +126,7 @@ feature 'Integration settings' do
expect(page).to have_content('Resend Request') expect(page).to have_content('Resend Request')
end end
scenario 'retry hook log' do it 'retry hook log' do
WebMock.stub_request(:post, hook.url) WebMock.stub_request(:post, hook.url)
hook_log hook_log
......
require 'rails_helper'
describe 'Projects > Settings > LFS settings' do
let(:admin) { create(:admin) }
let(:project) { create(:project) }
context 'LFS enabled setting' do
before do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
sign_in(admin)
end
it 'displays the correct elements', :js do
visit edit_project_path(project)
expect(page).to have_content('Git Large File Storage')
expect(page).to have_selector('input[name="project[lfs_enabled]"] + button', visible: true)
end
end
end
require 'spec_helper' require 'spec_helper'
feature "Pipelines settings" do describe "Projects > Settings > Pipelines settings" do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:role) { :developer } let(:role) { :developer }
background do before do
sign_in(user) sign_in(user)
project.add_role(user, role) project.add_role(user, role)
end end
context 'for developer' do context 'for developer' do
given(:role) { :developer } let(:role) { :developer }
scenario 'to be disallowed to view' do it 'to be disallowed to view' do
visit project_settings_ci_cd_path(project) visit project_settings_ci_cd_path(project)
expect(page.status_code).to eq(404) expect(page.status_code).to eq(404)
...@@ -21,9 +21,9 @@ feature "Pipelines settings" do ...@@ -21,9 +21,9 @@ feature "Pipelines settings" do
end end
context 'for master' do context 'for master' do
given(:role) { :master } let(:role) { :master }
scenario 'be allowed to change' do it 'be allowed to change' do
visit project_settings_ci_cd_path(project) visit project_settings_ci_cd_path(project)
fill_in('Test coverage parsing', with: 'coverage_regex') fill_in('Test coverage parsing', with: 'coverage_regex')
...@@ -34,7 +34,7 @@ feature "Pipelines settings" do ...@@ -34,7 +34,7 @@ feature "Pipelines settings" do
expect(page).to have_field('Test coverage parsing', with: 'coverage_regex') expect(page).to have_field('Test coverage parsing', with: 'coverage_regex')
end end
scenario 'updates auto_cancel_pending_pipelines' do it 'updates auto_cancel_pending_pipelines' do
visit project_settings_ci_cd_path(project) visit project_settings_ci_cd_path(project)
page.check('Auto-cancel redundant, pending pipelines') page.check('Auto-cancel redundant, pending pipelines')
......
require 'spec_helper' require 'spec_helper'
feature 'Repository settings' do describe 'Projects > Settings > Repository settings' do
let(:project) { create(:project_empty_repo) } let(:project) { create(:project_empty_repo) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:role) { :developer } let(:role) { :developer }
background do before do
project.add_role(user, role) project.add_role(user, role)
sign_in(user) sign_in(user)
end end
context 'for developer' do context 'for developer' do
given(:role) { :developer } let(:role) { :developer }
scenario 'is not allowed to view' do it 'is not allowed to view' do
visit project_settings_repository_path(project) visit project_settings_repository_path(project)
expect(page.status_code).to eq(404) expect(page.status_code).to eq(404)
...@@ -21,14 +21,14 @@ feature 'Repository settings' do ...@@ -21,14 +21,14 @@ feature 'Repository settings' do
end end
context 'for master' do context 'for master' do
given(:role) { :master } let(:role) { :master }
context 'Deploy Keys', :js do context 'Deploy Keys', :js do
let(:private_deploy_key) { create(:deploy_key, title: 'private_deploy_key', public: false) } let(:private_deploy_key) { create(:deploy_key, title: 'private_deploy_key', public: false) }
let(:public_deploy_key) { create(:another_deploy_key, title: 'public_deploy_key', public: true) } let(:public_deploy_key) { create(:another_deploy_key, title: 'public_deploy_key', public: true) }
let(:new_ssh_key) { attributes_for(:key)[:key] } let(:new_ssh_key) { attributes_for(:key)[:key] }
scenario 'get list of keys' do it 'get list of keys' do
project.deploy_keys << private_deploy_key project.deploy_keys << private_deploy_key
project.deploy_keys << public_deploy_key project.deploy_keys << public_deploy_key
...@@ -38,7 +38,7 @@ feature 'Repository settings' do ...@@ -38,7 +38,7 @@ feature 'Repository settings' do
expect(page).to have_content('public_deploy_key') expect(page).to have_content('public_deploy_key')
end end
scenario 'add a new deploy key' do it 'add a new deploy key' do
visit project_settings_repository_path(project) visit project_settings_repository_path(project)
fill_in 'deploy_key_title', with: 'new_deploy_key' fill_in 'deploy_key_title', with: 'new_deploy_key'
...@@ -50,7 +50,7 @@ feature 'Repository settings' do ...@@ -50,7 +50,7 @@ feature 'Repository settings' do
expect(page).to have_content('Write access allowed') expect(page).to have_content('Write access allowed')
end end
scenario 'edit an existing deploy key' do it 'edit an existing deploy key' do
project.deploy_keys << private_deploy_key project.deploy_keys << private_deploy_key
visit project_settings_repository_path(project) visit project_settings_repository_path(project)
...@@ -64,7 +64,7 @@ feature 'Repository settings' do ...@@ -64,7 +64,7 @@ feature 'Repository settings' do
expect(page).to have_content('Write access allowed') expect(page).to have_content('Write access allowed')
end end
scenario 'edit a deploy key from projects user has access to' do it 'edit a deploy key from projects user has access to' do
project2 = create(:project_empty_repo) project2 = create(:project_empty_repo)
project2.add_role(user, role) project2.add_role(user, role)
project2.deploy_keys << private_deploy_key project2.deploy_keys << private_deploy_key
...@@ -79,7 +79,7 @@ feature 'Repository settings' do ...@@ -79,7 +79,7 @@ feature 'Repository settings' do
expect(page).to have_content('updated_deploy_key') expect(page).to have_content('updated_deploy_key')
end end
scenario 'remove an existing deploy key' do it 'remove an existing deploy key' do
project.deploy_keys << private_deploy_key project.deploy_keys << private_deploy_key
visit project_settings_repository_path(project) visit project_settings_repository_path(project)
......
require 'spec_helper' require 'spec_helper'
describe 'User archives a project' do describe 'Projects > Settings > User archives a project' do
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.add_master(user) project.add_master(user)
sign_in(user) sign_in(user)
visit edit_project_path(project)
end end
context 'when a project is archived' do context 'when a project is archived' do
let(:project) { create(:project, :archived, namespace: user.namespace) } let(:project) { create(:project, :archived, namespace: user.namespace) }
before do
visit(edit_project_path(project))
end
it 'unarchives a project' do it 'unarchives a project' do
expect(page).to have_content('Unarchive project') expect(page).to have_content('Unarchive project')
...@@ -28,10 +26,6 @@ describe 'User archives a project' do ...@@ -28,10 +26,6 @@ describe 'User archives a project' do
context 'when a project is unarchived' do context 'when a project is unarchived' do
let(:project) { create(:project, :repository, namespace: user.namespace) } let(:project) { create(:project, :repository, namespace: user.namespace) }
before do
visit(edit_project_path(project))
end
it 'archives a project' do it 'archives a project' do
expect(page).to have_content('Archive project') expect(page).to have_content('Archive project')
......
require 'spec_helper'
describe 'Projects > Settings > User changes avatar' do
let(:project) { create(:project, :repository) }
let(:user) { project.creator }
before do
project.add_master(user)
sign_in(user)
end
it 'saves the new avatar' do
expect(project.reload.avatar.url).to be_nil
save_avatar(project)
expect(project.reload.avatar.url).to eq "/uploads/-/system/project/avatar/#{project.id}/banana_sample.gif"
end
context 'with an avatar already set' do
before do
save_avatar(project)
end
it 'is possible to remove the avatar' do
click_link 'Remove avatar'
expect(page).not_to have_link('Remove avatar')
expect(project.reload.avatar.url).to be_nil
end
end
def save_avatar(project)
visit edit_project_path(project)
attach_file(
:project_avatar,
File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')
)
page.within '.general-settings' do
click_button 'Save changes'
end
end
end
require 'spec_helper'
describe 'Projects > Settings > User changes default branch' do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, namespace: user.namespace) }
before do
sign_in(user)
visit edit_project_path(project)
end
it 'allows to change the default branch' do
select 'fix', from: 'project_default_branch'
page.within '.general-settings' do
click_button 'Save changes'
end
expect(find(:css, 'select#project_default_branch').value).to eq 'fix'
end
end
require 'spec_helper' require 'spec_helper'
describe 'User manages group links' do describe 'Projects > Settings > User manages group links' do
include Select2Helper include Select2Helper
let(:user) { create(:user) } let(:user) { create(:user) }
......
require 'spec_helper' require 'spec_helper'
feature 'Project settings > Merge Requests', :js do describe 'Projects > Settings > User manages merge request settings' do
let(:project) { create(:project, :public) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :public, namespace: user.namespace, path: 'gitlab', name: 'sample') }
background do before do
project.add_master(user)
sign_in(user) sign_in(user)
visit edit_project_path(project)
end end
context 'when Merge Request and Pipelines are initially enabled' do it 'shows "Merge commit" strategy' do
context 'when Pipelines are initially enabled' do page.within '.merge-requests-feature' do
before do expect(page).to have_content 'Merge commit'
visit edit_project_path(project) end
end
it 'shows "Merge commit with semi-linear history " strategy' do
page.within '.merge-requests-feature' do
expect(page).to have_content 'Merge commit with semi-linear history'
end
end end
scenario 'shows the Merge Requests settings' do it 'shows "Fast-forward merge" strategy' do
page.within '.merge-requests-feature' do
expect(page).to have_content 'Fast-forward merge'
end
end
context 'when Merge Request and Pipelines are initially enabled', :js do
context 'when Pipelines are initially enabled' do
it 'shows the Merge Requests settings' do
expect(page).to have_content('Only allow merge requests to be merged if the pipeline succeeds') expect(page).to have_content('Only allow merge requests to be merged if the pipeline succeeds')
expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved') expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved')
...@@ -29,13 +43,13 @@ feature 'Project settings > Merge Requests', :js do ...@@ -29,13 +43,13 @@ feature 'Project settings > Merge Requests', :js do
end end
end end
context 'when Pipelines are initially disabled' do context 'when Pipelines are initially disabled', :js do
before do before do
project.project_feature.update_attribute('builds_access_level', ProjectFeature::DISABLED) project.project_feature.update_attribute('builds_access_level', ProjectFeature::DISABLED)
visit edit_project_path(project) visit edit_project_path(project)
end end
scenario 'shows the Merge Requests settings that do not depend on Builds feature' do it 'shows the Merge Requests settings that do not depend on Builds feature' do
expect(page).not_to have_content('Only allow merge requests to be merged if the pipeline succeeds') expect(page).not_to have_content('Only allow merge requests to be merged if the pipeline succeeds')
expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved') expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved')
...@@ -50,13 +64,13 @@ feature 'Project settings > Merge Requests', :js do ...@@ -50,13 +64,13 @@ feature 'Project settings > Merge Requests', :js do
end end
end end
context 'when Merge Request are initially disabled' do context 'when Merge Request are initially disabled', :js do
before do before do
project.project_feature.update_attribute('merge_requests_access_level', ProjectFeature::DISABLED) project.project_feature.update_attribute('merge_requests_access_level', ProjectFeature::DISABLED)
visit edit_project_path(project) visit edit_project_path(project)
end end
scenario 'does not show the Merge Requests settings' do it 'does not show the Merge Requests settings' do
expect(page).not_to have_content('Only allow merge requests to be merged if the pipeline succeeds') expect(page).not_to have_content('Only allow merge requests to be merged if the pipeline succeeds')
expect(page).not_to have_content('Only allow merge requests to be merged if all discussions are resolved') expect(page).not_to have_content('Only allow merge requests to be merged if all discussions are resolved')
...@@ -70,17 +84,13 @@ feature 'Project settings > Merge Requests', :js do ...@@ -70,17 +84,13 @@ feature 'Project settings > Merge Requests', :js do
end end
end end
describe 'Checkbox to enable merge request link' do describe 'Checkbox to enable merge request link', :js do
before do it 'is initially checked' do
visit edit_project_path(project)
end
scenario 'is initially checked' do
checkbox = find_field('project_printing_merge_request_link_enabled') checkbox = find_field('project_printing_merge_request_link_enabled')
expect(checkbox).to be_checked expect(checkbox).to be_checked
end end
scenario 'when unchecked sets :printing_merge_request_link_enabled to false' do it 'when unchecked sets :printing_merge_request_link_enabled to false' do
uncheck('project_printing_merge_request_link_enabled') uncheck('project_printing_merge_request_link_enabled')
within('.merge-request-settings-form') do within('.merge-request-settings-form') do
click_on('Save changes') click_on('Save changes')
......
require 'spec_helper' require 'spec_helper'
describe 'User manages project members' do describe 'Projects > Settings > User manages project members' do
let(:group) { create(:group, name: 'OpenSource') } let(:group) { create(:group, name: 'OpenSource') }
let(:project) { create(:project) } let(:project) { create(:project) }
let(:project2) { create(:project) } let(:project2) { create(:project) }
......
require 'spec_helper'
describe 'Projects > Settings > User renames a project' do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace, path: 'gitlab', name: 'sample') }
before do
sign_in(user)
visit edit_project_path(project)
end
def rename_project(project, name: nil, path: nil)
fill_in('project_name', with: name) if name
fill_in('Path', with: path) if path
click_button('Rename project')
wait_for_edit_project_page_reload
project.reload
end
def wait_for_edit_project_page_reload
expect(find('.project-edit-container')).to have_content('Rename repository')
end
context 'with invalid characters' do
it 'shows errors for invalid project path/name' do
rename_project(project, name: 'foo&bar', path: 'foo&bar')
expect(page).to have_field 'Project name', with: 'foo&bar'
expect(page).to have_field 'Path', with: 'foo&bar'
expect(page).to have_content "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'."
expect(page).to have_content "Path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'"
end
end
it 'shows a successful notice when the project is updated' do
fill_in 'project_name_edit', with: 'hello world'
page.within('.general-settings') do
click_button 'Save changes'
end
expect(page).to have_content "Project 'hello world' was successfully updated."
end
context 'when changing project name' do
it 'renames the repository' do
rename_project(project, name: 'bar')
expect(find('.breadcrumbs')).to have_content(project.name)
end
context 'with emojis' do
it 'shows error for invalid project name' do
rename_project(project, name: '🚀 foo bar ☁️')
expect(page).to have_field 'Project name', with: '🚀 foo bar ☁️'
expect(page).not_to have_content "Name can contain only letters, digits, emojis '_', '.', dash and space. It must start with letter, digit, emoji or '_'."
end
end
end
context 'when changing project path' do
let(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') }
before(:context) do
TestEnv.clean_test_path
end
after do
TestEnv.clean_test_path
end
it 'the project is accessible via the new path' do
rename_project(project, path: 'bar')
new_path = namespace_project_path(project.namespace, 'bar')
visit new_path
expect(current_path).to eq(new_path)
expect(find('.breadcrumbs')).to have_content(project.name)
end
it 'the project is accessible via a redirect from the old path' do
old_path = project_path(project)
rename_project(project, path: 'bar')
new_path = namespace_project_path(project.namespace, 'bar')
visit old_path
expect(current_path).to eq(new_path)
expect(find('.breadcrumbs')).to have_content(project.name)
end
context 'and a new project is added with the same path' do
it 'overrides the redirect' do
old_path = project_path(project)
rename_project(project, path: 'bar')
new_project = create(:project, namespace: user.namespace, path: 'gitlabhq', name: 'quz')
visit old_path
expect(current_path).to eq(old_path)
expect(find('.breadcrumbs')).to have_content(new_project.name)
end
end
end
end
require 'spec_helper'
describe 'Projects > Settings > User tags a project' do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
before do
sign_in(user)
visit edit_project_path(project)
end
context 'when a project is archived' do
it 'unarchives a project' do
fill_in 'Tags', with: 'tag1, tag2'
page.within '.general-settings' do
click_button 'Save changes'
end
expect(find_field('Tags').value).to eq 'tag1, tag2'
end
end
end
require 'spec_helper' require 'spec_helper'
feature 'User transfers a project', :js do describe 'Projects > Settings > User transfers a project', :js do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :repository, namespace: user.namespace) } let(:project) { create(:project, :repository, namespace: user.namespace) }
let(:group) { create(:group) }
before do before do
sign_in user group.add_owner(user)
sign_in(user)
end end
def transfer_project(project, group) def transfer_project(project, group)
...@@ -26,20 +28,42 @@ feature 'User transfers a project', :js do ...@@ -26,20 +28,42 @@ feature 'User transfers a project', :js do
wait_for_requests wait_for_requests
end end
it 'allows transferring a project to a subgroup of a namespace' do it 'allows transferring a project to a group' do
group = create(:group) old_path = project_path(project)
group.add_owner(user)
transfer_project(project, group) transfer_project(project, group)
new_path = namespace_project_path(group, project)
expect(project.reload.namespace).to eq(group) expect(project.reload.namespace).to eq(group)
visit new_path
wait_for_requests
expect(current_path).to eq(new_path)
expect(find('.breadcrumbs')).to have_content(project.name)
visit old_path
wait_for_requests
expect(current_path).to eq(new_path)
expect(find('.breadcrumbs')).to have_content(project.name)
end
context 'and a new project is added with the same path' do
it 'overrides the redirect' do
old_path = project_path(project)
project_path = project.path
transfer_project(project, group)
new_project = create(:project, namespace: user.namespace, path: project_path)
visit old_path
expect(current_path).to eq(old_path)
expect(find('.breadcrumbs')).to have_content(new_project.name)
end
end end
context 'when nested groups are available', :nested_groups do context 'when nested groups are available', :nested_groups do
it 'allows transferring a project to a subgroup' do it 'allows transferring a project to a subgroup' do
parent = create(:group) subgroup = create(:group, parent: group)
parent.add_owner(user)
subgroup = create(:group, parent: parent)
transfer_project(project, subgroup) transfer_project(project, subgroup)
......
require 'spec_helper' require 'spec_helper'
feature 'Visibility settings', :js do describe 'Projects > Settings > Visibility settings', :js do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace, visibility_level: 20) } let(:project) { create(:project, namespace: user.namespace, visibility_level: 20) }
...@@ -10,14 +10,14 @@ feature 'Visibility settings', :js do ...@@ -10,14 +10,14 @@ feature 'Visibility settings', :js do
visit edit_project_path(project) visit edit_project_path(project)
end end
scenario 'project visibility select is available' do it 'project visibility select is available' do
visibility_select_container = find('.project-visibility-setting') visibility_select_container = find('.project-visibility-setting')
expect(visibility_select_container.find('select').value).to eq project.visibility_level.to_s expect(visibility_select_container.find('select').value).to eq project.visibility_level.to_s
expect(visibility_select_container).to have_content 'The project can be accessed by anyone, regardless of authentication.' expect(visibility_select_container).to have_content 'The project can be accessed by anyone, regardless of authentication.'
end end
scenario 'project visibility description updates on change' do it 'project visibility description updates on change' do
visibility_select_container = find('.project-visibility-setting') visibility_select_container = find('.project-visibility-setting')
visibility_select = visibility_select_container.find('select') visibility_select = visibility_select_container.find('select')
visibility_select.select('Private') visibility_select.select('Private')
...@@ -25,6 +25,38 @@ feature 'Visibility settings', :js do ...@@ -25,6 +25,38 @@ feature 'Visibility settings', :js do
expect(visibility_select.value).to eq '0' expect(visibility_select.value).to eq '0'
expect(visibility_select_container).to have_content 'Access must be granted explicitly to each user.' expect(visibility_select_container).to have_content 'Access must be granted explicitly to each user.'
end end
context 'merge requests select' do
it 'hides merge requests section' do
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
expect(page).to have_selector('.merge-requests-feature', visible: false)
end
context 'given project with merge_requests_disabled access level' do
let(:project) { create(:project, :merge_requests_disabled, namespace: user.namespace) }
it 'hides merge requests section' do
expect(page).to have_selector('.merge-requests-feature', visible: false)
end
end
end
context 'builds select' do
it 'hides builds select section' do
find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .project-feature-toggle').click
expect(page).to have_selector('.builds-feature', visible: false)
end
context 'given project with builds_disabled access level' do
let(:project) { create(:project, :builds_disabled, namespace: user.namespace) }
it 'hides builds select section' do
expect(page).to have_selector('.builds-feature', visible: false)
end
end
end
end end
context 'as master' do context 'as master' do
...@@ -36,7 +68,7 @@ feature 'Visibility settings', :js do ...@@ -36,7 +68,7 @@ feature 'Visibility settings', :js do
visit edit_project_path(project) visit edit_project_path(project)
end end
scenario 'project visibility is locked' do it 'project visibility is locked' do
visibility_select_container = find('.project-visibility-setting') visibility_select_container = find('.project-visibility-setting')
expect(visibility_select_container).to have_selector 'select[name="project[visibility_level]"]:disabled' expect(visibility_select_container).to have_selector 'select[name="project[visibility_level]"]:disabled'
......
require 'rails_helper' require 'rails_helper'
feature 'Developer views empty project instructions' do feature 'Projects > Show > Developer views empty project instructions' do
let(:project) { create(:project, :empty_repo) } let(:project) { create(:project, :empty_repo) }
let(:developer) { create(:user) } let(:developer) { create(:user) }
......
require 'spec_helper' require 'spec_helper'
feature 'Download buttons in project main page' do feature 'Projects > Show > Download buttons' do
given(:user) { create(:user) } given(:user) { create(:user) }
given(:role) { :developer } given(:role) { :developer }
given(:status) { 'success' } given(:status) { 'success' }
......
require 'spec_helper' require 'spec_helper'
describe 'Project redirects' do describe 'Projects > Show > Redirects' do
let(:user) { create :user } let(:user) { create :user }
let(:public_project) { create :project, :public } let(:public_project) { create :project, :public }
let(:private_project) { create :project, :private } let(:private_project) { create :project, :private }
......
require 'spec_helper' require 'spec_helper'
feature 'Project RSS' do feature 'Projects > Show > RSS' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
let(:path) { project_path(project) } let(:path) { project_path(project) }
......
require 'spec_helper' require 'spec_helper'
describe 'User interacts with project stars' do describe 'Projects > Show > User interacts with project stars' do
let(:project) { create(:project, :public, :repository) } let(:project) { create(:project, :public, :repository) }
context 'when user is signed in', :js do context 'when user is signed in', :js do
......
require 'spec_helper'
describe 'Projects > Show > User manages notifications', :js do
let(:project) { create(:project, :public, :repository) }
before do
sign_in(project.owner)
visit project_path(project)
end
it 'changes the notification setting' do
first('.notifications-btn').click
click_link 'On mention'
page.within '#notifications-button' do
expect(page).to have_content 'On mention'
end
end
end
require 'spec_helper'
describe 'Projects > Show > User sees a deletion failure message' do
let(:project) { create(:project, :empty_repo, pending_delete: true) }
before do
sign_in(project.owner)
end
it 'shows error message if deletion for project fails' do
project.update_attributes(delete_error: "Something went wrong", pending_delete: false)
visit project_path(project)
expect(page).to have_selector('.project-deletion-failed-message')
expect(page).to have_content("This project was scheduled for deletion, but failed with the following message: #{project.delete_error}")
end
end
require 'spec_helper' require 'spec_helper'
describe 'User views details' do describe 'Projects > Show > User sees Git instructions' do
set(:user) { create(:user) } set(:user) { create(:user) }
shared_examples_for 'redirects to the sign in page' do shared_examples_for 'redirects to the sign in page' do
...@@ -9,6 +9,16 @@ describe 'User views details' do ...@@ -9,6 +9,16 @@ describe 'User views details' do
end end
end end
shared_examples_for 'shows details of empty project with no repo' do
it 'shows Git command line instructions' do
click_link 'Create empty repository'
page.within '.empty_wrapper' do
expect(page).to have_content('Command line instructions')
end
end
end
shared_examples_for 'shows details of empty project' do shared_examples_for 'shows details of empty project' do
let(:user_has_ssh_key) { false } let(:user_has_ssh_key) { false }
...@@ -36,6 +46,17 @@ describe 'User views details' do ...@@ -36,6 +46,17 @@ describe 'User views details' do
end end
context 'when project is public' do context 'when project is public' do
context 'when project has no repo' do
set(:project) { create(:project, :public) }
before do
sign_in(project.owner)
visit project_path(project)
end
include_examples 'shows details of empty project with no repo'
end
context 'when project is empty' do context 'when project is empty' do
set(:project) { create(:project_empty_repo, :public) } set(:project) { create(:project_empty_repo, :public) }
......
require 'spec_helper'
describe 'Projects > Show > User sees last commit CI status' do
set(:project) { create(:project, :repository, :public) }
it 'shows the project README', :js do
project.enable_ci
pipeline = create(:ci_pipeline, project: project, sha: project.commit.sha, ref: 'master')
pipeline.skip
visit project_path(project)
page.within '.blob-commit-info' do
expect(page).to have_content(project.commit.sha[0..6])
expect(page).to have_link('Commit: skipped')
end
end
end
require 'spec_helper'
describe 'Projects > Show > User sees README' do
set(:user) { create(:user) }
set(:project) { create(:project, :repository, :public) }
it 'shows the project README', :js do
visit project_path(project)
wait_for_requests
page.within('.readme-holder') do
expect(page).to have_content 'testme'
end
end
end
require 'spec_helper'
describe 'Projects > Show > User sees setup shortcut buttons' do
# For "New file", "Add License" functionality,
# see spec/features/projects/files/project_owner_creates_license_file_spec.rb
# see spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb
let(:user) { create(:user) }
describe 'empty project' do
let(:project) { create(:project, :public, :empty_repo) }
let(:presenter) { project.present(current_user: user) }
describe 'as a normal user' do
before do
sign_in(user)
visit project_path(project)
end
it 'no Auto DevOps button if can not manage pipelines' do
page.within('.project-stats') do
expect(page).not_to have_link('Enable Auto DevOps')
expect(page).not_to have_link('Auto DevOps enabled')
end
end
it '"Auto DevOps enabled" button not linked' do
project.create_auto_devops!(enabled: true)
visit project_path(project)
page.within('.project-stats') do
expect(page).to have_text('Auto DevOps enabled')
end
end
end
describe 'as a master' do
before do
project.add_master(user)
sign_in(user)
visit project_path(project)
end
it '"New file" button linked to new file page' do
page.within('.project-stats') do
expect(page).to have_link('New file', href: project_new_blob_path(project, project.default_branch || 'master'))
end
end
it '"Add Readme" button linked to new file populated for a readme' do
page.within('.project-stats') do
expect(page).to have_link('Add Readme', href: presenter.add_readme_path)
end
end
it '"Add License" button linked to new file populated for a license' do
page.within('.project-stats') do
expect(page).to have_link('Add License', href: presenter.add_license_path)
end
end
describe 'Auto DevOps button' do
it '"Enable Auto DevOps" button linked to settings page' do
page.within('.project-stats') do
expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
end
end
it '"Auto DevOps enabled" anchor linked to settings page' do
project.create_auto_devops!(enabled: true)
visit project_path(project)
page.within('.project-stats') do
expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
end
end
end
describe 'Kubernetes cluster button' do
it '"Add Kubernetes cluster" button linked to clusters page' do
page.within('.project-stats') do
expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project))
end
end
it '"Kubernetes cluster" anchor linked to cluster page' do
cluster = create(:cluster, :provided_by_gcp, projects: [project])
visit project_path(project)
page.within('.project-stats') do
expect(page).to have_link('Kubernetes configured', href: project_cluster_path(project, cluster))
end
end
end
end
end
describe 'populated project' do
let(:project) { create(:project, :public, :repository) }
let(:presenter) { project.present(current_user: user) }
describe 'as a normal user' do
before do
sign_in(user)
visit project_path(project)
end
it 'no Auto DevOps button if can not manage pipelines' do
page.within('.project-stats') do
expect(page).not_to have_link('Enable Auto DevOps')
expect(page).not_to have_link('Auto DevOps enabled')
end
end
it '"Auto DevOps enabled" button not linked' do
project.create_auto_devops!(enabled: true)
visit project_path(project)
page.within('.project-stats') do
expect(page).to have_text('Auto DevOps enabled')
end
end
it 'no Kubernetes cluster button if can not manage clusters' do
page.within('.project-stats') do
expect(page).not_to have_link('Add Kubernetes cluster')
expect(page).not_to have_link('Kubernetes configured')
end
end
end
describe 'as a master' do
before do
allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(false)
project.add_master(user)
sign_in(user)
visit project_path(project)
end
it 'no "Add Changelog" button if the project already has a changelog' do
expect(project.repository.changelog).not_to be_nil
page.within('.project-stats') do
expect(page).not_to have_link('Add Changelog')
end
end
it 'no "Add License" button if the project already has a license' do
expect(project.repository.license_blob).not_to be_nil
page.within('.project-stats') do
expect(page).not_to have_link('Add License')
end
end
it 'no "Add Contribution guide" button if the project already has a contribution guide' do
expect(project.repository.contribution_guide).not_to be_nil
page.within('.project-stats') do
expect(page).not_to have_link('Add Contribution guide')
end
end
describe 'GitLab CI configuration button' do
it '"Set up CI/CD" button linked to new file populated for a .gitlab-ci.yml' do
expect(project.repository.gitlab_ci_yml).to be_nil
page.within('.project-stats') do
expect(page).to have_link('Set up CI/CD', href: presenter.add_ci_yml_path)
end
end
it 'no "Set up CI/CD" button if the project already has a .gitlab-ci.yml' do
Files::CreateService.new(
project,
project.creator,
start_branch: 'master',
branch_name: 'master',
commit_message: "Add .gitlab-ci.yml",
file_path: '.gitlab-ci.yml',
file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
).execute
expect(project.repository.gitlab_ci_yml).not_to be_nil
visit project_path(project)
page.within('.project-stats') do
expect(page).not_to have_link('Set up CI/CD')
end
end
it 'no "Set up CI/CD" button if the project has Auto DevOps enabled' do
project.create_auto_devops!(enabled: true)
visit project_path(project)
page.within('.project-stats') do
expect(page).not_to have_link('Set up CI/CD')
end
end
end
describe 'Auto DevOps button' do
it '"Enable Auto DevOps" button linked to settings page' do
page.within('.project-stats') do
expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
end
end
it '"Enable Auto DevOps" button linked to settings page' do
project.create_auto_devops!(enabled: true)
visit project_path(project)
page.within('.project-stats') do
expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
end
end
it 'no Auto DevOps button if Auto DevOps callout is shown' do
allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(true)
visit project_path(project)
expect(page).to have_selector('.js-autodevops-banner')
page.within('.project-stats') do
expect(page).not_to have_link('Enable Auto DevOps')
expect(page).not_to have_link('Auto DevOps enabled')
end
end
it 'no "Enable Auto DevOps" button when .gitlab-ci.yml already exists' do
Files::CreateService.new(
project,
project.creator,
start_branch: 'master',
branch_name: 'master',
commit_message: "Add .gitlab-ci.yml",
file_path: '.gitlab-ci.yml',
file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
).execute
expect(project.repository.gitlab_ci_yml).not_to be_nil
visit project_path(project)
page.within('.project-stats') do
expect(page).not_to have_link('Enable Auto DevOps')
expect(page).not_to have_link('Auto DevOps enabled')
end
end
end
describe 'Kubernetes cluster button' do
it '"Add Kubernetes cluster" button linked to clusters page' do
page.within('.project-stats') do
expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project))
end
end
it '"Kubernetes cluster" button linked to cluster page' do
cluster = create(:cluster, :provided_by_gcp, projects: [project])
visit project_path(project)
page.within('.project-stats') do
expect(page).to have_link('Kubernetes configured', href: project_cluster_path(project, cluster))
end
end
end
describe '"Set up Koding" button' do
it 'no "Set up Koding" button if Koding disabled' do
stub_application_setting(koding_enabled?: false)
visit project_path(project)
page.within('.project-stats') do
expect(page).not_to have_link('Set up Koding')
end
end
it 'no "Set up Koding" button if the project already has a .koding.yml' do
stub_application_setting(koding_enabled?: true)
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:koding_url).and_return('http://koding.example.com')
expect(project.repository.changelog).not_to be_nil
allow_any_instance_of(Repository).to receive(:koding_yml).and_return(project.repository.changelog)
visit project_path(project)
page.within('.project-stats') do
expect(page).not_to have_link('Set up Koding')
end
end
it '"Set up Koding" button linked to new file populated for a .koding.yml' do
stub_application_setting(koding_enabled?: true)
visit project_path(project)
page.within('.project-stats') do
expect(page).to have_link('Set up Koding', href: presenter.add_koding_stack_path)
end
end
end
end
end
end
require 'spec_helper'
describe 'Project show page', :feature do
include DropzoneHelper
context 'when project pending delete' do
let(:project) { create(:project, :empty_repo, pending_delete: true) }
before do
sign_in(project.owner)
end
it 'shows error message if deletion for project fails' do
project.update_attributes(delete_error: "Something went wrong", pending_delete: false)
visit project_path(project)
expect(page).to have_selector('.project-deletion-failed-message')
expect(page).to have_content("This project was scheduled for deletion, but failed with the following message: #{project.delete_error}")
end
end
describe 'stat button existence' do
# For "New file", "Add License" functionality,
# see spec/features/projects/files/project_owner_creates_license_file_spec.rb
# see spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb
let(:user) { create(:user) }
describe 'empty project' do
let(:project) { create(:project, :public, :empty_repo) }
let(:presenter) { project.present(current_user: user) }
describe 'as a normal user' do
before do
sign_in(user)
visit project_path(project)
end
it 'no Auto DevOps button if can not manage pipelines' do
page.within('.project-stats') do
expect(page).not_to have_link('Enable Auto DevOps')
expect(page).not_to have_link('Auto DevOps enabled')
end
end
it '"Auto DevOps enabled" button not linked' do
project.create_auto_devops!(enabled: true)
visit project_path(project)
page.within('.project-stats') do
expect(page).to have_text('Auto DevOps enabled')
end
end
end
describe 'as a master' do
before do
project.add_master(user)
sign_in(user)
visit project_path(project)
end
it '"New file" button linked to new file page' do
page.within('.project-stats') do
expect(page).to have_link('New file', href: project_new_blob_path(project, project.default_branch || 'master'))
end
end
it '"Add Readme" button linked to new file populated for a readme' do
page.within('.project-stats') do
expect(page).to have_link('Add Readme', href: presenter.add_readme_path)
end
end
it '"Add License" button linked to new file populated for a license' do
page.within('.project-stats') do
expect(page).to have_link('Add License', href: presenter.add_license_path)
end
end
describe 'Auto DevOps button' do
it '"Enable Auto DevOps" button linked to settings page' do
page.within('.project-stats') do
expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
end
end
it '"Auto DevOps enabled" anchor linked to settings page' do
project.create_auto_devops!(enabled: true)
visit project_path(project)
page.within('.project-stats') do
expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
end
end
end
describe 'Kubernetes cluster button' do
it '"Add Kubernetes cluster" button linked to clusters page' do
page.within('.project-stats') do
expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project))
end
end
it '"Kubernetes cluster" anchor linked to cluster page' do
cluster = create(:cluster, :provided_by_gcp, projects: [project])
visit project_path(project)
page.within('.project-stats') do
expect(page).to have_link('Kubernetes configured', href: project_cluster_path(project, cluster))
end
end
end
end
end
describe 'populated project' do
let(:project) { create(:project, :public, :repository) }
let(:presenter) { project.present(current_user: user) }
describe 'as a normal user' do
before do
sign_in(user)
visit project_path(project)
end
it 'no Auto DevOps button if can not manage pipelines' do
page.within('.project-stats') do
expect(page).not_to have_link('Enable Auto DevOps')
expect(page).not_to have_link('Auto DevOps enabled')
end
end
it '"Auto DevOps enabled" button not linked' do
project.create_auto_devops!(enabled: true)
visit project_path(project)
page.within('.project-stats') do
expect(page).to have_text('Auto DevOps enabled')
end
end
it 'no Kubernetes cluster button if can not manage clusters' do
page.within('.project-stats') do
expect(page).not_to have_link('Add Kubernetes cluster')
expect(page).not_to have_link('Kubernetes configured')
end
end
end
describe 'as a master' do
before do
allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(false)
project.add_master(user)
sign_in(user)
visit project_path(project)
end
it 'no "Add Changelog" button if the project already has a changelog' do
expect(project.repository.changelog).not_to be_nil
page.within('.project-stats') do
expect(page).not_to have_link('Add Changelog')
end
end
it 'no "Add License" button if the project already has a license' do
expect(project.repository.license_blob).not_to be_nil
page.within('.project-stats') do
expect(page).not_to have_link('Add License')
end
end
it 'no "Add Contribution guide" button if the project already has a contribution guide' do
expect(project.repository.contribution_guide).not_to be_nil
page.within('.project-stats') do
expect(page).not_to have_link('Add Contribution guide')
end
end
describe 'GitLab CI configuration button' do
it '"Set up CI/CD" button linked to new file populated for a .gitlab-ci.yml' do
expect(project.repository.gitlab_ci_yml).to be_nil
page.within('.project-stats') do
expect(page).to have_link('Set up CI/CD', href: presenter.add_ci_yml_path)
end
end
it 'no "Set up CI/CD" button if the project already has a .gitlab-ci.yml' do
Files::CreateService.new(
project,
project.creator,
start_branch: 'master',
branch_name: 'master',
commit_message: "Add .gitlab-ci.yml",
file_path: '.gitlab-ci.yml',
file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
).execute
expect(project.repository.gitlab_ci_yml).not_to be_nil
visit project_path(project)
page.within('.project-stats') do
expect(page).not_to have_link('Set up CI/CD')
end
end
it 'no "Set up CI/CD" button if the project has Auto DevOps enabled' do
project.create_auto_devops!(enabled: true)
visit project_path(project)
page.within('.project-stats') do
expect(page).not_to have_link('Set up CI/CD')
end
end
end
describe 'Auto DevOps button' do
it '"Enable Auto DevOps" button linked to settings page' do
page.within('.project-stats') do
expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
end
end
it '"Enable Auto DevOps" button linked to settings page' do
project.create_auto_devops!(enabled: true)
visit project_path(project)
page.within('.project-stats') do
expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings'))
end
end
it 'no Auto DevOps button if Auto DevOps callout is shown' do
allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(true)
visit project_path(project)
expect(page).to have_selector('.js-autodevops-banner')
page.within('.project-stats') do
expect(page).not_to have_link('Enable Auto DevOps')
expect(page).not_to have_link('Auto DevOps enabled')
end
end
it 'no "Enable Auto DevOps" button when .gitlab-ci.yml already exists' do
Files::CreateService.new(
project,
project.creator,
start_branch: 'master',
branch_name: 'master',
commit_message: "Add .gitlab-ci.yml",
file_path: '.gitlab-ci.yml',
file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
).execute
expect(project.repository.gitlab_ci_yml).not_to be_nil
visit project_path(project)
page.within('.project-stats') do
expect(page).not_to have_link('Enable Auto DevOps')
expect(page).not_to have_link('Auto DevOps enabled')
end
end
end
describe 'Kubernetes cluster button' do
it '"Add Kubernetes cluster" button linked to clusters page' do
page.within('.project-stats') do
expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project))
end
end
it '"Kubernetes cluster" button linked to cluster page' do
cluster = create(:cluster, :provided_by_gcp, projects: [project])
visit project_path(project)
page.within('.project-stats') do
expect(page).to have_link('Kubernetes configured', href: project_cluster_path(project, cluster))
end
end
end
describe '"Set up Koding" button' do
it 'no "Set up Koding" button if Koding disabled' do
stub_application_setting(koding_enabled?: false)
visit project_path(project)
page.within('.project-stats') do
expect(page).not_to have_link('Set up Koding')
end
end
it 'no "Set up Koding" button if the project already has a .koding.yml' do
stub_application_setting(koding_enabled?: true)
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:koding_url).and_return('http://koding.example.com')
expect(project.repository.changelog).not_to be_nil
allow_any_instance_of(Repository).to receive(:koding_yml).and_return(project.repository.changelog)
visit project_path(project)
page.within('.project-stats') do
expect(page).not_to have_link('Set up Koding')
end
end
it '"Set up Koding" button linked to new file populated for a .koding.yml' do
stub_application_setting(koding_enabled?: true)
visit project_path(project)
page.within('.project-stats') do
expect(page).to have_link('Set up Koding', href: presenter.add_koding_stack_path)
end
end
end
end
end
end
describe 'dropzone', :js do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
project.add_master(user)
sign_in(user)
visit project_path(project)
end
it 'can upload files' do
find('.add-to-tree').click
click_link 'Upload file'
drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
expect(find('.dz-filename')).to have_content('doc_sample.txt')
end
end
end
require 'rails_helper' require 'rails_helper'
feature 'Create Snippet', :js do describe 'Projects > Snippets > Create Snippet', :js do
include DropzoneHelper include DropzoneHelper
let(:user) { create(:user) } let(:user) { create(:user) }
......
require 'spec_helper' require 'spec_helper'
feature 'Project snippet', :js do describe 'Projects > Snippets > Project snippet', :js do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:snippet) { create(:project_snippet, project: project, file_name: file_name, content: content) } let(:snippet) { create(:project_snippet, project: project, file_name: file_name, content: content) }
......
require 'spec_helper' require 'spec_helper'
describe 'User comments on a snippet', :js do describe 'Projects > Snippets > User comments on a snippet', :js do
let(:project) { create(:project) } let(:project) { create(:project) }
let!(:snippet) { create(:project_snippet, project: project, author: user) } let!(:snippet) { create(:project_snippet, project: project, author: user) }
let(:user) { create(:user) } let(:user) { create(:user) }
...@@ -22,4 +22,16 @@ describe 'User comments on a snippet', :js do ...@@ -22,4 +22,16 @@ describe 'User comments on a snippet', :js do
expect(page).to have_content('Good snippet!') expect(page).to have_content('Good snippet!')
end end
it 'should have autocomplete' do
find('#note_note').native.send_keys('')
fill_in 'note[note]', with: '@'
expect(page).to have_selector('.atwho-view')
end
it 'should have zen mode' do
find('.js-zen-enter').click()
expect(page).to have_selector('.fullscreen')
end
end end
require 'spec_helper' require 'spec_helper'
describe 'User deletes a snippet' do describe 'Projects > Snippets > User deletes a snippet' do
let(:project) { create(:project) } let(:project) { create(:project) }
let!(:snippet) { create(:project_snippet, project: project, author: user) } let!(:snippet) { create(:project_snippet, project: project, author: user) }
let(:user) { create(:user) } let(:user) { create(:user) }
......
require 'spec_helper' require 'spec_helper'
describe 'User updates a snippet' do describe 'Projects > Snippets > User updates a snippet' do
let(:project) { create(:project) } let(:project) { create(:project) }
let!(:snippet) { create(:project_snippet, project: project, author: user) } let!(:snippet) { create(:project_snippet, project: project, author: user) }
let(:user) { create(:user) } let(:user) { create(:user) }
......
require 'spec_helper' require 'spec_helper'
describe 'User views snippets' do describe 'Projects > Snippets > User views snippets' do
let(:project) { create(:project) } let(:project) { create(:project) }
let!(:project_snippet) { create(:project_snippet, project: project, author: user) } let!(:project_snippet) { create(:project_snippet, project: project, author: user) }
let!(:snippet) { create(:snippet, author: user) } let!(:snippet) { create(:snippet, author: user) }
let(:snippets) { [project_snippet, snippet] } # Used by the shared examples
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
...@@ -13,6 +14,17 @@ describe 'User views snippets' do ...@@ -13,6 +14,17 @@ describe 'User views snippets' do
visit(project_snippets_path(project)) visit(project_snippets_path(project))
end end
context 'pagination' do
before do
create(:project_snippet, project: project, author: user)
allow(Snippet).to receive(:default_per_page).and_return(1)
visit project_snippets_path(project)
end
it_behaves_like 'paginated snippets'
end
it 'shows snippets' do it 'shows snippets' do
expect(page).to have_content(project_snippet.title) expect(page).to have_content(project_snippet.title)
expect(page).not_to have_content(snippet.title) expect(page).not_to have_content(snippet.title)
......
require 'spec_helper'
describe 'Project snippets', :js do
context 'when the project has snippets' do
let(:project) { create(:project, :public) }
let!(:snippets) { create_list(:project_snippet, 2, :public, author: project.owner, project: project) }
let!(:other_snippet) { create(:project_snippet) }
context 'pagination' do
before do
allow(Snippet).to receive(:default_per_page).and_return(1)
visit project_snippets_path(project)
end
it_behaves_like 'paginated snippets'
end
context 'list content' do
it 'contains all project snippets' do
visit project_snippets_path(project)
expect(page).to have_selector('.snippet-row', count: 2)
expect(page).to have_content(snippets[0].title)
expect(page).to have_content(snippets[1].title)
end
end
context 'when submitting a note' do
before do
sign_in(create(:admin))
visit project_snippet_path(project, snippets[0])
end
it 'should have autocomplete' do
find('#note_note').native.send_keys('')
fill_in 'note[note]', with: '@'
expect(page).to have_selector('.atwho-view')
end
it 'should have zen mode' do
find('.js-zen-enter').click()
expect(page).to have_selector('.fullscreen')
end
end
end
end
require 'spec_helper'
describe 'Projects > User sees sidebar' do
let(:user) { create(:user) }
let(:project) { create(:project, :private, public_builds: false, namespace: user.namespace) }
context 'as owner' do
before do
sign_in(user)
end
context 'when snippets are disabled' do
before do
project.project_feature.update_attribute('snippets_access_level', ProjectFeature::DISABLED)
end
it 'does not display a "Snippets" link' do
visit project_path(project)
within('.nav-sidebar') do
expect(page).not_to have_content 'Snippets'
end
end
end
end
context 'as guest' do
let(:guest) { create(:user) }
before do
project.add_guest(guest)
sign_in(guest)
end
it 'shows allowed tabs only' do
visit project_path(project)
within('.nav-sidebar') do
expect(page).to have_content 'Overview'
expect(page).to have_content 'Issues'
expect(page).to have_content 'Wiki'
expect(page).not_to have_content 'Repository'
expect(page).not_to have_content 'CI / CD'
expect(page).not_to have_content 'Merge Requests'
end
end
it 'does not show fork button' do
visit project_path(project)
within('.count-buttons') do
expect(page).not_to have_link 'Fork'
end
end
it 'does not show clone path' do
visit project_path(project)
within('.project-repo-buttons') do
expect(page).not_to have_selector '.project-clone-holder'
end
end
describe 'project landing page' do
before do
project.project_feature.update!(
issues_access_level: ProjectFeature::DISABLED,
wiki_access_level: ProjectFeature::DISABLED
)
end
it 'does not show the project file list landing page' do
visit project_path(project)
expect(page).not_to have_selector '.project-stats'
expect(page).not_to have_selector '.project-last-commit'
expect(page).not_to have_selector '.project-show-files'
expect(page).to have_selector '.project-show-customize_workflow'
end
it 'shows the customize workflow when issues and wiki are disabled' do
visit project_path(project)
expect(page).to have_selector '.project-show-customize_workflow'
end
it 'shows the wiki when enabled' do
project.project_feature.update!(wiki_access_level: ProjectFeature::PRIVATE)
visit project_path(project)
expect(page).to have_selector '.project-show-wiki'
end
it 'shows the issues when enabled' do
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
visit project_path(project)
expect(page).to have_selector '.issues-list'
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment