Commit af89b19d authored by Alexander Randa's avatar Alexander Randa

Replaces 'dashboard/new-project.feature' spinach with rspec

parent a8bc8d4d
---
title: Replace 'dashboard/new-project.feature' spinach with rspec
merge_request: 12550
author: Alexander Randa (@randaalex)
@dashboard
Feature: New Project
Background:
Given I sign in as a user
And I own project "Shop"
And I visit dashboard page
And I click "New project" link
@javascript
Scenario: I should see New Projects page
Then I see "New Project" page
Then I see all possible import options
@javascript
Scenario: I should see instructions on how to import from Git URL
Given I see "New Project" page
When I click on "Repo by URL"
Then I see instructions on how to import from Git URL
@javascript
Scenario: I should see instructions on how to import from GitHub
Given I see "New Project" page
When I click on "Import project from GitHub"
Then I am redirected to the GitHub import page
@javascript
Scenario: I should see Google Code import page
Given I see "New Project" page
When I click on "Google Code"
Then I redirected to Google Code import page
class Spinach::Features::NewProject < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedProject
step 'I click "New project" link' do
page.within '#content-body' do
click_link "New project"
end
end
step 'I click "New project" in top right menu' do
page.within '.header-content' do
click_link "New project"
end
end
step 'I see "New Project" page' do
expect(page).to have_content('Project path')
expect(page).to have_content('Project name')
end
step 'I see all possible import options' do
expect(page).to have_link('GitHub')
expect(page).to have_link('Bitbucket')
expect(page).to have_link('GitLab.com')
expect(page).to have_link('Google Code')
expect(page).to have_button('Repo by URL')
expect(page).to have_link('GitLab export')
end
step 'I click on "Import project from GitHub"' do
first('.import_github').click
end
step 'I am redirected to the GitHub import page' do
expect(page).to have_content('Import Projects from GitHub')
expect(current_path).to eq new_import_github_path
end
step 'I click on "Repo by URL"' do
first('.import_git').click
end
step 'I see instructions on how to import from Git URL' do
git_import_instructions = first('.js-toggle-content')
expect(git_import_instructions).to be_visible
expect(git_import_instructions).to have_content "Git repository URL"
end
step 'I click on "Google Code"' do
first('.import_google_code').click
end
step 'I redirected to Google Code import page' do
expect(page).to have_content('Import projects from Google Code')
expect(current_path).to eq new_import_google_code_path
end
end
class Spinach::Features::DashboardStarredProjects < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedProject
step 'I starred project "Community"' do
current_user.toggle_star(Project.find_by(name: 'Community'))
end
step 'I should not see project "Shop"' do
page.within '.projects-list' do
expect(page).not_to have_content('Shop')
end
end
end
require 'spec_helper'
RSpec.describe 'Dashboard Projects', feature: true do
feature 'Dashboard Projects' do
let(:user) { create(:user) }
let(:project) { create(:project, name: "awesome stuff") }
let(:project) { create(:project, name: 'awesome stuff') }
let(:project2) { create(:project, :public, name: 'Community project') }
before do
......@@ -15,6 +15,14 @@ RSpec.describe 'Dashboard Projects', feature: true do
expect(page).to have_content('awesome stuff')
end
it 'shows "New project" button' do
visit dashboard_projects_path
page.within '#content-body' do
expect(page).to have_link('New project')
end
end
context 'when last_repository_updated_at, last_activity_at and update_at are present' do
it 'shows the last_repository_updated_at attribute as the update date' do
project.update_attributes!(last_repository_updated_at: Time.now, last_activity_at: 1.hour.ago)
......@@ -47,8 +55,8 @@ RSpec.describe 'Dashboard Projects', feature: true do
end
end
describe "with a pipeline", redis: true do
let!(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit.sha) }
describe 'with a pipeline', redis: true do
let(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit.sha) }
before do
# Since the cache isn't updated when a new pipeline is created
......
require "spec_helper"
require 'spec_helper'
feature "New project", feature: true do
feature 'New project' do
let(:user) { create(:admin) }
before do
gitlab_sign_in(user)
sign_in(user)
end
context "Visibility level selector" do
it 'shows "New project" page' do
visit new_project_path
expect(page).to have_content('Project path')
expect(page).to have_content('Project name')
expect(page).to have_link('GitHub')
expect(page).to have_link('Bitbucket')
expect(page).to have_link('GitLab.com')
expect(page).to have_link('Google Code')
expect(page).to have_button('Repo by URL')
expect(page).to have_link('GitLab export')
end
context 'Visibility level selector' do
Gitlab::VisibilityLevel.options.each do |key, level|
it "sets selector to #{key}" do
stub_application_setting(default_project_visibility: level)
......@@ -28,20 +42,20 @@ feature "New project", feature: true do
end
end
context "Namespace selector" do
context "with user namespace" do
context 'Namespace selector' do
context 'with user namespace' do
before do
visit new_project_path
end
it "selects the user namespace" do
namespace = find("#project_namespace_id")
it 'selects the user namespace' do
namespace = find('#project_namespace_id')
expect(namespace.text).to eq user.username
end
end
context "with group namespace" do
context 'with group namespace' do
let(:group) { create(:group, :private, owner: user) }
before do
......@@ -49,13 +63,13 @@ feature "New project", feature: true do
visit new_project_path(namespace_id: group.id)
end
it "selects the group namespace" do
namespace = find("#project_namespace_id option[selected]")
it 'selects the group namespace' do
namespace = find('#project_namespace_id option[selected]')
expect(namespace.text).to eq group.name
end
context "on validation error" do
context 'on validation error' do
before do
fill_in('project_path', with: 'private-group-project')
choose('Internal')
......@@ -64,15 +78,15 @@ feature "New project", feature: true do
expect(page).to have_css '.project-edit-errors .alert.alert-danger'
end
it "selects the group namespace" do
namespace = find("#project_namespace_id option[selected]")
it 'selects the group namespace' do
namespace = find('#project_namespace_id option[selected]')
expect(namespace.text).to eq group.name
end
end
end
context "with subgroup namespace" do
context 'with subgroup namespace' do
let(:group) { create(:group, :private, owner: user) }
let(:subgroup) { create(:group, parent: group) }
......@@ -81,8 +95,8 @@ feature "New project", feature: true do
visit new_project_path(namespace_id: subgroup.id)
end
it "selects the group namespace" do
namespace = find("#project_namespace_id option[selected]")
it 'selects the group namespace' do
namespace = find('#project_namespace_id option[selected]')
expect(namespace.text).to eq subgroup.full_path
end
......@@ -94,10 +108,45 @@ feature "New project", feature: true do
visit new_project_path
end
context 'from git repository url' do
before do
first('.import_git').click
end
it 'does not autocomplete sensitive git repo URL' do
autocomplete = find('#project_import_url')['autocomplete']
expect(autocomplete).to eq('off')
end
it 'shows import instructions' do
git_import_instructions = first('.js-toggle-content')
expect(git_import_instructions).to be_visible
expect(git_import_instructions).to have_content 'Git repository URL'
end
end
context 'from GitHub' do
before do
first('.import_github').click
end
it 'shows import instructions' do
expect(page).to have_content('Import Projects from GitHub')
expect(current_path).to eq new_import_github_path
end
end
context 'from Google Code' do
before do
first('.import_google_code').click
end
it 'shows import instructions' do
expect(page).to have_content('Import projects from Google Code')
expect(current_path).to eq new_import_google_code_path
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