Replace the 'features/explore/projects.feature' spinach test with an rspec analog

parent 2a9147b7
---
title: Replace the 'features/explore/projects.feature' spinach test with an rspec analog
merge_request: 14755
author: Vitaliy @blackst0ne Klachkov
type: other
@public
Feature: Explore Projects
Background:
Given public project "Community"
And internal project "Internal"
And private project "Enterprise"
Scenario: I visit public area
Given archived project "Archive"
When I visit the public projects area
Then I should see project "Community"
And I should not see project "Internal"
And I should not see project "Enterprise"
And I should not see project "Archive"
Scenario: I visit public project page
When I visit project "Community" page
Then I should see project "Community" home page
Scenario: I visit internal project page
When I visit project "Internal" page
Then I should be redirected to sign in page
Scenario: I visit private project page
When I visit project "Enterprise" page
Then I should be redirected to sign in page
Scenario: I visit an empty public project page
Given public empty project "Empty Public Project"
When I visit empty project page
Then I should see empty public project details
And I should see empty public project details with http clone info
Scenario: I visit an empty public project page as user with no ssh-keys
Given I sign in as a user
And I have no ssh keys
And public empty project "Empty Public Project"
When I visit empty project page
Then I should see empty public project details
And I should see empty public project details with http clone info
Scenario: I visit an empty public project page as user with an ssh-key
Given I sign in as a user
And I have an ssh key
And public empty project "Empty Public Project"
When I visit empty project page
Then I should see empty public project details
And I should see empty public project details with ssh clone info
Scenario: I visit public area as user
Given archived project "Archive"
And I sign in as a user
When I visit the public projects area
Then I should see project "Community"
And I should see project "Internal"
And I should not see project "Enterprise"
And I should not see project "Archive"
Scenario: I visit internal project page as user
Given I sign in as a user
When I visit project "Internal" page
Then I should see project "Internal" home page
Scenario: I visit public project page
When I visit project "Community" page
Then I should see project "Community" home page
And I should see an http link to the repository
Scenario: I visit public project page as user with no ssh-keys
Given I sign in as a user
And I have no ssh keys
When I visit project "Community" page
Then I should see project "Community" home page
And I should see an http link to the repository
Scenario: I visit public project page as user with an ssh-key
Given I sign in as a user
And I have an ssh key
When I visit project "Community" page
Then I should see project "Community" home page
And I should see an ssh link to the repository
Scenario: I visit an empty public project page
Given public empty project "Empty Public Project"
When I visit empty project page
Then I should see empty public project details
Scenario: I visit public project issues page as a non authorized user
Given I visit project "Community" page
Then I should not see command line instructions
And I visit "Community" issues page
Then I should see list of issues for "Community" project
Scenario: I visit public project issues page as authorized user
Given I sign in as a user
Given I visit project "Community" page
And I visit "Community" issues page
Then I should see list of issues for "Community" project
Scenario: I visit internal project issues page as authorized user
Given I sign in as a user
Given I visit project "Internal" page
And I visit "Internal" issues page
Then I should see list of issues for "Internal" project
Scenario: I visit public project merge requests page as an authorized user
Given I sign in as a user
Given I visit project "Community" page
And I visit "Community" merge requests page
And project "Community" has "Bug fix" open merge request
Then I should see list of merge requests for "Community" project
Scenario: I visit public project merge requests page as a non authorized user
Given I visit project "Community" page
And I visit "Community" merge requests page
And project "Community" has "Bug fix" open merge request
Then I should see list of merge requests for "Community" project
Scenario: I visit internal project merge requests page as an authorized user
Given I sign in as a user
Given I visit project "Internal" page
And I visit "Internal" merge requests page
And project "Internal" has "Feature implemented" open merge request
Then I should see list of merge requests for "Internal" project
Scenario: Trending page
Given archived project "Archive"
And project "Archive" has comments
And I sign in as a user
And project "Community" has comments
And trending projects are refreshed
When I visit the explore trending projects
Then I should see project "Community"
And I should not see project "Internal"
And I should not see project "Enterprise"
And I should not see project "Archive"
Scenario: Most starred page
Given archived project "Archive"
And I sign in as a user
When I visit the explore starred projects
Then I should see project "Community"
And I should see project "Internal"
And I should not see project "Archive"
class Spinach::Features::ExploreProjects < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedProject
include SharedUser
step 'I should see project "Empty Public Project"' do
expect(page).to have_content "Empty Public Project"
end
step 'I should see public project details' do
expect(page).to have_content '32 branches'
expect(page).to have_content '16 tags'
end
step 'I should see project readme' do
expect(page).to have_content 'README.md'
end
step 'I should see empty public project details' do
expect(page).not_to have_content 'Git global setup'
end
step 'I should see empty public project details with http clone info' do
project = Project.find_by(name: 'Empty Public Project')
page.all(:css, '.git-empty .clone').each do |element|
expect(element.text).to include(project.http_url_to_repo)
end
end
step 'I should see empty public project details with ssh clone info' do
project = Project.find_by(name: 'Empty Public Project')
page.all(:css, '.git-empty .clone').each do |element|
expect(element.text).to include(project.url_to_repo)
end
end
step 'I should see project "Community" home page' do
page.within '.breadcrumbs .breadcrumb-item-text' do
expect(page).to have_content 'Community'
end
end
step 'I should see project "Internal" home page' do
page.within '.breadcrumbs .breadcrumb-item-text' do
expect(page).to have_content 'Internal'
end
end
step 'I should see an http link to the repository' do
project = Project.find_by(name: 'Community')
expect(page).to have_field('project_clone', with: project.http_url_to_repo)
end
step 'I should see an ssh link to the repository' do
project = Project.find_by(name: 'Community')
expect(page).to have_field('project_clone', with: project.url_to_repo)
end
step 'I visit "Community" issues page' do
create(:issue,
title: "Bug",
project: public_project
)
create(:issue,
title: "New feature",
project: public_project
)
visit project_issues_path(public_project)
end
step 'I should see list of issues for "Community" project' do
expect(page).to have_content "Bug"
expect(page).to have_content public_project.name
expect(page).to have_content "New feature"
end
step 'I visit "Internal" issues page' do
create(:issue,
title: "Internal Bug",
project: internal_project
)
create(:issue,
title: "New internal feature",
project: internal_project
)
visit project_issues_path(internal_project)
end
step 'I should see list of issues for "Internal" project' do
expect(page).to have_content "Internal Bug"
expect(page).to have_content internal_project.name
expect(page).to have_content "New internal feature"
end
step 'I visit "Community" merge requests page' do
visit project_merge_requests_path(public_project)
end
step 'project "Community" has "Bug fix" open merge request' do
create(:merge_request,
title: "Bug fix for public project",
source_project: public_project,
target_project: public_project
)
end
step 'I should see list of merge requests for "Community" project' do
expect(page).to have_content public_project.name
expect(page).to have_content public_merge_request.source_project.name
end
step 'I visit "Internal" merge requests page' do
visit project_merge_requests_path(internal_project)
end
step 'project "Internal" has "Feature implemented" open merge request' do
create(:merge_request,
title: "Feature implemented",
source_project: internal_project,
target_project: internal_project
)
end
step 'I should see list of merge requests for "Internal" project' do
expect(page).to have_content internal_project.name
expect(page).to have_content internal_merge_request.source_project.name
end
def internal_project
@internal_project ||= Project.find_by!(name: 'Internal')
end
def public_project
@public_project ||= Project.find_by!(name: 'Community')
end
def internal_merge_request
@internal_merge_request ||= MergeRequest.find_by!(title: 'Feature implemented')
end
def public_merge_request
@public_merge_request ||= MergeRequest.find_by!(title: 'Bug fix for public project')
end
end
......@@ -454,19 +454,6 @@ module SharedPaths
# ----------------------------------------
# Public Projects
# ----------------------------------------
step 'I visit the public projects area' do
visit explore_projects_path
end
step 'I visit the explore trending projects' do
visit trending_explore_projects_path
end
step 'I visit the explore starred projects' do
visit starred_explore_projects_path
end
step 'I visit the public groups area' do
visit explore_groups_path
end
......
......@@ -112,10 +112,6 @@ module SharedProject
# Visibility of archived project
# ----------------------------------------
step 'archived project "Archive"' do
create(:project, :archived, :public, :repository, name: 'Archive')
end
step 'I should not see project "Archive"' do
project = Project.find_by(name: "Archive")
expect(page).not_to have_content project.name_with_namespace
......@@ -126,11 +122,6 @@ module SharedProject
expect(page).to have_content project.name_with_namespace
end
step 'project "Archive" has comments' do
project = Project.find_by(name: "Archive")
2.times { create(:note_on_issue, project: project) }
end
# ----------------------------------------
# Visibility level
# ----------------------------------------
......@@ -209,15 +200,6 @@ module SharedProject
create :project_empty_repo, :public, name: "Empty Public Project"
end
step 'project "Community" has comments' do
project = Project.find_by(name: "Community")
2.times { create(:note_on_issue, project: project) }
end
step 'trending projects are refreshed' do
TrendingProject.refresh!
end
step 'project "Shop" has labels: "bug", "feature", "enhancement"' do
project = Project.find_by(name: "Shop")
create(:label, project: project, title: 'bug')
......
require 'spec_helper'
describe 'User explores projects' do
set(:archived_project) { create(:project, :archived) }
set(:internal_project) { create(:project, :internal) }
set(:private_project) { create(:project, :private) }
set(:public_project) { create(:project, :public) }
shared_examples_for 'shows public projects' do
it 'shows projects' do
expect(page).to have_content(public_project.title)
expect(page).not_to have_content(internal_project.title)
expect(page).not_to have_content(private_project.title)
expect(page).not_to have_content(archived_project.title)
end
end
shared_examples_for 'shows public and internal projects' do
it 'shows projects' do
expect(page).to have_content(public_project.title)
expect(page).to have_content(internal_project.title)
expect(page).not_to have_content(private_project.title)
expect(page).not_to have_content(archived_project.title)
end
end
context 'when not signed in' do
context 'when viewing public projects' do
before do
visit(explore_projects_path)
end
include_examples 'shows public projects'
end
end
context 'when signed in' do
set(:user) { create(:user) }
before do
sign_in(user)
end
context 'when viewing public projects' do
before do
visit(explore_projects_path)
end
include_examples 'shows public and internal projects'
end
context 'when viewing most starred projects' do
before do
visit(starred_explore_projects_path)
end
include_examples 'shows public and internal projects'
end
context 'when viewing trending projects' do
before do
[archived_project, public_project].each { |project| create(:note_on_issue, project: project) }
TrendingProject.refresh!
visit(trending_explore_projects_path)
end
include_examples 'shows public projects'
end
end
end
require 'spec_helper'
feature 'Issues List' do
let(:user) { create(:user) }
let(:project) { create(:project) }
background do
project.team << [user, :developer]
sign_in(user)
end
scenario 'user does not see create new list button' do
create(:issue, project: project)
visit project_issues_path(project)
expect(page).not_to have_selector('.js-new-board-list')
end
end
require 'spec_helper'
describe 'User views issues' do
set(:user) { create(:user) }
shared_examples_for 'shows issues' do
it 'shows issues' do
expect(page).to have_content(project.name)
.and have_content(issue1.title)
.and have_content(issue2.title)
.and have_no_selector('.js-new-board-list')
end
end
context 'when project is public' do
set(:project) { create(:project_empty_repo, :public) }
set(:issue1) { create(:issue, project: project) }
set(:issue2) { create(:issue, project: project) }
context 'when signed in' do
before do
project.add_developer(user)
sign_in(user)
visit(project_issues_path(project))
end
include_examples 'shows issues'
end
context 'when not signed in' do
before do
visit(project_issues_path(project))
end
include_examples 'shows issues'
end
end
context 'when project is internal' do
set(:project) { create(:project_empty_repo, :internal) }
set(:issue1) { create(:issue, project: project) }
set(:issue2) { create(:issue, project: project) }
context 'when signed in' do
before do
project.add_developer(user)
sign_in(user)
visit(project_issues_path(project))
end
include_examples 'shows issues'
end
end
end
require 'spec_helper'
describe 'User views open merge requests' do
let(:project) { create(:project, :public, :repository) }
set(:user) { create(:user) }
shared_examples_for 'shows merge requests' do
it 'shows merge requests' do
expect(page).to have_content(project.name).and have_content(merge_request.source_project.name)
end
end
context 'when project is public' do
set(:project) { create(:project, :public, :repository) }
context 'when not signed in' do
context "when the target branch is the project's default branch" do
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let!(:closed_merge_request) { create(:closed_merge_request, source_project: project, target_project: project) }
......@@ -11,6 +21,8 @@ describe 'User views open merge requests' do
visit(project_merge_requests_path(project))
end
include_examples 'shows merge requests'
it 'shows open merge requests' do
expect(page).to have_content(merge_request.title).and have_no_content(closed_merge_request.title)
end
......@@ -69,4 +81,35 @@ describe 'User views open merge requests' do
end
end
end
end
context 'when signed in' do
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
before do
project.add_developer(user)
sign_in(user)
visit(project_merge_requests_path(project))
end
include_examples 'shows merge requests'
end
end
context 'when project is internal' do
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
set(:project) { create(:project, :internal, :repository) }
context 'when signed in' do
before do
project.add_developer(user)
sign_in(user)
visit(project_merge_requests_path(project))
end
include_examples 'shows merge requests'
end
end
end
require 'spec_helper'
describe 'User views details' do
set(:user) { create(:user) }
shared_examples_for 'redirects to the sign in page' do
it 'redirects to the sign in page' do
expect(current_path).to eq(new_user_session_path)
end
end
shared_examples_for 'shows details of empty project' do
let(:user_has_ssh_key) { false }
it 'shows details' do
expect(page).not_to have_content('Git global setup')
page.all(:css, '.git-empty .clone').each do |element|
expect(element.text).to include(project.http_url_to_repo)
end
expect(page).to have_field('project_clone', with: project.http_url_to_repo) unless user_has_ssh_key
end
end
shared_examples_for 'shows details of non empty project' do
let(:user_has_ssh_key) { false }
it 'shows details' do
page.within('.breadcrumbs .breadcrumb-item-text') do
expect(page).to have_content(project.title)
end
expect(page).to have_field('project_clone', with: project.http_url_to_repo) unless user_has_ssh_key
end
end
context 'when project is public' do
context 'when project is empty' do
set(:project) { create(:project_empty_repo, :public) }
context 'when not signed in' do
before do
visit(project_path(project))
end
include_examples 'shows details of empty project'
end
context 'when signed in' do
before do
sign_in(user)
end
context 'when user does not have ssh keys' do
before do
visit(project_path(project))
end
include_examples 'shows details of empty project'
end
context 'when user has ssh keys' do
before do
create(:personal_key, user: user)
visit(project_path(project))
end
include_examples 'shows details of empty project' do
let(:user_has_ssh_key) { true }
end
end
end
end
context 'when project is not empty' do
set(:project) { create(:project, :public, :repository) }
before do
visit(project_path(project))
end
context 'when not signed in' do
before do
allow(Gitlab.config.gitlab).to receive(:host).and_return('www.example.com')
end
include_examples 'shows details of non empty project'
end
context 'when signed in' do
before do
sign_in(user)
end
context 'when user does not have ssh keys' do
before do
visit(project_path(project))
end
include_examples 'shows details of non empty project'
end
context 'when user has ssh keys' do
before do
create(:personal_key, user: user)
visit(project_path(project))
end
include_examples 'shows details of non empty project' do
let(:user_has_ssh_key) { true }
end
end
end
end
end
context 'when project is internal' do
set(:project) { create(:project, :internal, :repository) }
context 'when not signed in' do
before do
visit(project_path(project))
end
include_examples 'redirects to the sign in page'
end
context 'when signed in' do
before do
sign_in(user)
visit(project_path(project))
end
include_examples 'shows details of non empty project'
end
end
context 'when project is private' do
set(:project) { create(:project, :private) }
before do
visit(project_path(project))
end
include_examples 'redirects to the sign in page'
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