Commit 029b5c04 authored by Robert Speicher's avatar Robert Speicher

Add "Developer views empty project instructions" feature spec

This removes several Spinach features and step definitions
parent 4485f376
......@@ -5,50 +5,10 @@ Feature: Project Create
Should be able to create a new one
@javascript
Scenario: User create a project with Kerberos disabled
Scenario: User create a project
Given I sign in as a user
And KRB5 disabled
When I visit new project page
And I have an ssh key
And fill project form with valid data
Then I should see project page
And I should see empty project instructions
@javascript
Scenario: User create a project with Kerberos enabled
Given I sign in as a user
And KRB5 enabled
When I visit new project page
And I have an ssh key
And fill project form with valid data
Then I should see project page
And I should see empty project instructions with Kerberos as default url
@javascript
Scenario: Empty project instructions with Kerberos disabled
Given I sign in as a user
And KRB5 disabled
And I have an ssh key
When I visit new project page
And fill project form with valid data
Then I see empty project instructions
And I click on HTTP
Then Remote url should update to http link
And If I click on SSH
Then Remote url should update to ssh link
@javascript
Scenario: Empty project instructions with Kerberos enabled
Given I sign in as a user
Given KRB5 enabled
And I have an ssh key
When I visit new project page
And fill project form with valid data
Then I see empty project instructions with Kerberos as default url
And I click on HTTP
Then Remote url should update to http link
And If I click on SSH
Then Remote url should update to ssh link
And If I click on KRB5
Then Remote url should update to kerberos link
And KRB5 disabled
And I should see empty project instructions
......@@ -18,59 +18,4 @@ class Spinach::Features::ProjectCreate < Spinach::FeatureSteps
expect(page).to have_content "git remote"
expect(page).to have_content Project.last.url_to_repo
end
step 'I should see empty project instructions with Kerberos as default url' do
expect(page).to have_content "git init"
expect(page).to have_content "git remote"
expect(page).to have_content Project.last.kerberos_url_to_repo
end
step 'KRB5 enabled' do
# Enable Kerberos in an alternative port to force Kerberos button and URL to show up in the UI
allow(Gitlab.config.kerberos).to receive(:enabled).and_return(true)
allow(Gitlab.config.kerberos).to receive(:use_dedicated_port).and_return(true)
end
step 'KRB5 disabled' do
allow(Gitlab.config.kerberos).to receive(:enabled).and_return(false)
end
step 'I see empty project instructions' do
expect(page).to have_content "git init"
expect(page).to have_content "git remote"
expect(page).to have_content Project.last.url_to_repo
end
step 'I see empty project instructions with Kerberos as default url' do
expect(page).to have_content "git init"
expect(page).to have_content "git remote"
expect(page).to have_content Project.last.kerberos_url_to_repo
end
step 'I click on HTTP' do
find('#clone-dropdown').click
find('.http-selector').click
end
step 'Remote url should update to http link' do
expect(page).to have_content "git remote add origin #{Project.last.http_url_to_repo}"
end
step 'If I click on SSH' do
find('#clone-dropdown').click
find('.ssh-selector').click
end
step 'Remote url should update to ssh link' do
expect(page).to have_content "git remote add origin #{Project.last.url_to_repo}"
end
step 'If I click on KRB5' do
find('#clone-dropdown').click
find('.kerberos-selector').click
end
step 'Remote url should update to kerberos link' do
expect(page).to have_content "git remote add origin #{Project.last.kerberos_url_to_repo}"
end
end
......@@ -92,6 +92,12 @@ FactoryGirl.define do
mirror true
mirror_user_id { creator_id }
end
trait :empty_repo do
after(:create) do |project|
project.create_repository
end
end
end
# Project with empty repository
......@@ -99,9 +105,7 @@ FactoryGirl.define do
# This is a case when you just created a project
# but not pushed any code there yet
factory :project_empty_repo, parent: :empty_project do
after :create do |project|
project.create_repository
end
empty_repo
end
# Project with test repository
......
require 'rails_helper'
feature 'Developer views empty project instructions', feature: true do
let(:project) { create(:empty_project, :empty_repo) }
let(:developer) { create(:user) }
background do
project.team << [developer, :developer]
login_as(developer)
end
context 'without an SSH key' do
scenario 'defaults to HTTP' do
visit_project
expect_instructions_for('http')
end
scenario 'switches to SSH', js: true do
visit_project
select_protocol('SSH')
expect_instructions_for('ssh')
end
end
context 'with an SSH key' do
background do
create(:personal_key, user: developer)
end
scenario 'defaults to SSH' do
visit_project
expect_instructions_for('ssh')
end
scenario 'switches to HTTP', js: true do
visit_project
select_protocol('HTTP')
expect_instructions_for('http')
end
end
context 'with Kerberos enabled' do
background do
allow(Gitlab.config.kerberos).to receive(:enabled).and_return(true)
end
scenario 'defaults to KRB5' do
visit_project
expect_instructions_for('kerberos')
end
end
def visit_project
visit namespace_project_path(project.namespace, project)
end
def select_protocol(protocol)
find('#clone-dropdown').click
find(".#{protocol.downcase}-selector").click
end
def expect_instructions_for(protocol)
msg = :"#{protocol.downcase}_url_to_repo"
expect(page).to have_content("git clone #{project.send(msg)}")
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