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
@project.add_master(@user)
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
@project ||= Project.first
end
......@@ -206,24 +140,6 @@ module SharedProject
create(:label, project: project, title: 'enhancement')
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
@project.update(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
end
......
require 'spec_helper'
feature 'Project Activity RSS' do
let(:user) { create(:user) }
let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
let(:project) { create(:project, :public) }
let(:user) { project.owner }
let(:path) { activity_project_path(project) }
before do
......@@ -11,8 +11,7 @@ feature 'Project Activity RSS' do
context 'when signed in' do
before do
project.add_developer(user)
sign_in(user)
sign_in(project.owner)
visit path
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 'fileutils'
feature 'User wants to add a Dockerfile file' do
describe 'Projects > Files > User wants to add a Dockerfile file' do
before do
user = create(:user)
project = create(:project, :repository)
project.add_master(user)
sign_in user
sign_in project.owner
visit project_new_blob_path(project, 'master', file_name: 'Dockerfile')
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')
end
scenario 'user can pick a Dockerfile file from the dropdown', :js do
find('.js-dockerfile-selector').click
wait_for_requests
......
require 'spec_helper'
feature 'Download buttons in files tree' do
given(:user) { create(:user) }
given(:role) { :developer }
given(:status) { 'success' }
given(:project) { create(:project, :repository) }
describe 'Projects > Files > Download buttons in files tree' do
let(:project) { create(:project, :repository) }
let(:user) { project.creator }
given(:pipeline) do
let(:pipeline) do
create(:ci_pipeline,
project: project,
sha: project.commit.sha,
ref: project.default_branch,
status: status)
status: 'success')
end
given!(:build) do
let!(:build) do
create(:ci_build, :success, :artifacts,
pipeline: pipeline,
status: pipeline.status,
name: 'build')
end
background do
before do
sign_in(user)
project.add_role(user, role)
end
project.add_developer(user)
describe 'when files tree' do
context 'with artifacts' do
before do
visit project_tree_path(project, project.default_branch)
end
visit project_tree_path(project, project.default_branch)
end
scenario 'shows download artifacts button' do
href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build')
context 'with artifacts' do
it 'shows download artifacts button' do
href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build')
expect(page).to have_link "Download '#{build.name}'", href: href
end
expect(page).to have_link "Download '#{build.name}'", href: href
end
end
end
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
user = create(:user)
project = create(:project, :repository)
project.add_master(user)
user = project.owner
sign_in user
visit project_new_blob_path(project, 'master', file_name: 'test_file-name')
page.within('.file-editor.code') do
......@@ -23,7 +22,7 @@ feature 'User uses soft wrap whilst editing file', :js do
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
toggle_button.click
expect(toggle_button).to have_content 'No wrap'
......
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(:user) { create(:user) }
let(:user) { project.owner }
let(:commit_params) do
{
start_branch: project.default_branch,
......@@ -15,14 +15,13 @@ feature 'User wants to edit a file' do
}
end
background do
project.add_master(user)
before do
sign_in user
visit project_edit_blob_path(project,
File.join(project.default_branch, '.gitignore'))
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
click_button 'Commit changes'
......
require 'spec_helper'
feature 'User views files page' do
let(:user) { create(:user) }
describe 'Projects > Files > User views files page' do
let(:project) { create(:forked_project_with_submodules) }
let(:user) { project.owner }
before do
project.add_master(user)
sign_in user
visit project_tree_path(project, project.repository.root_ref)
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)
tree = project.repository.tree
......
require 'spec_helper'
feature 'Find file keyboard shortcuts', :js do
let(:user) { create(:user) }
describe 'Projects > Files > Find file keyboard shortcuts', :js do
let(:project) { create(:project, :repository) }
let(:user) { project.owner }
before do
project.add_master(user)
sign_in user