2016-06-02 11:05:42 +05:30
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
feature 'Developer views empty project instructions' do
|
|
|
|
let(:project) { create(:project, :empty_repo) }
|
2016-06-02 11:05:42 +05:30
|
|
|
let(:developer) { create(:user) }
|
|
|
|
|
|
|
|
background do
|
|
|
|
project.team << [developer, :developer]
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
sign_in(developer)
|
2016-06-02 11:05:42 +05:30
|
|
|
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
|
|
|
|
|
|
|
|
def visit_project
|
2017-09-10 17:25:29 +05:30
|
|
|
visit project_path(project)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def select_protocol(protocol)
|
|
|
|
find('#clone-dropdown').click
|
|
|
|
find(".#{protocol.downcase}-selector").click
|
|
|
|
end
|
|
|
|
|
|
|
|
def expect_instructions_for(protocol)
|
2017-09-10 17:25:29 +05:30
|
|
|
msg = :"#{protocol.downcase}_url_to_repo"
|
|
|
|
|
|
|
|
expect(page).to have_content("git clone #{project.send(msg)}")
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|