2016-12-16 07:30:17 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
RSpec.describe 'admin deploy keys' do
|
2016-12-16 07:30:17 -05:00
|
|
|
let!(:deploy_key) { create(:deploy_key, public: true) }
|
|
|
|
let!(:another_deploy_key) { create(:another_deploy_key, public: true) }
|
|
|
|
|
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(create(:admin))
|
2016-12-16 07:30:17 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'show all public deploy keys' do
|
|
|
|
visit admin_deploy_keys_path
|
|
|
|
|
2017-03-31 08:54:38 -04:00
|
|
|
page.within(find('.deploy-keys-list', match: :first)) do
|
|
|
|
expect(page).to have_content(deploy_key.title)
|
|
|
|
expect(page).to have_content(another_deploy_key.title)
|
|
|
|
end
|
2016-12-16 07:30:17 -05:00
|
|
|
end
|
|
|
|
|
2018-01-05 10:23:44 -05:00
|
|
|
it 'shows all the projects the deploy key has write access' do
|
|
|
|
write_key = create(:deploy_keys_project, :write_access, deploy_key: deploy_key)
|
|
|
|
|
|
|
|
visit admin_deploy_keys_path
|
|
|
|
|
|
|
|
page.within(find('.deploy-keys-list', match: :first)) do
|
|
|
|
expect(page).to have_content(write_key.project.full_name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-31 08:54:38 -04:00
|
|
|
describe 'create a new deploy key' do
|
|
|
|
let(:new_ssh_key) { attributes_for(:key)[:key] }
|
|
|
|
|
2017-01-03 03:18:48 -05:00
|
|
|
before do
|
|
|
|
visit admin_deploy_keys_path
|
2017-04-04 18:36:19 -04:00
|
|
|
click_link 'New deploy key'
|
2017-01-03 03:18:48 -05:00
|
|
|
end
|
|
|
|
|
2017-03-31 08:54:38 -04:00
|
|
|
it 'creates a new deploy key' do
|
|
|
|
fill_in 'deploy_key_title', with: 'laptop'
|
|
|
|
fill_in 'deploy_key_key', with: new_ssh_key
|
2017-01-03 03:18:48 -05:00
|
|
|
click_button 'Create'
|
|
|
|
|
2017-03-31 08:54:38 -04:00
|
|
|
expect(current_path).to eq admin_deploy_keys_path
|
2017-01-03 03:18:48 -05:00
|
|
|
|
2017-03-31 08:54:38 -04:00
|
|
|
page.within(find('.deploy-keys-list', match: :first)) do
|
|
|
|
expect(page).to have_content('laptop')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-01-03 03:18:48 -05:00
|
|
|
|
2017-03-31 08:54:38 -04:00
|
|
|
describe 'update an existing deploy key' do
|
|
|
|
before do
|
|
|
|
visit admin_deploy_keys_path
|
|
|
|
find('tr', text: deploy_key.title).click_link('Edit')
|
2017-01-03 03:18:48 -05:00
|
|
|
end
|
2016-12-16 07:30:17 -05:00
|
|
|
|
2017-03-31 08:54:38 -04:00
|
|
|
it 'updates an existing deploy key' do
|
|
|
|
fill_in 'deploy_key_title', with: 'new-title'
|
|
|
|
click_button 'Save changes'
|
|
|
|
|
2017-01-03 03:18:48 -05:00
|
|
|
expect(current_path).to eq admin_deploy_keys_path
|
2017-03-31 08:54:38 -04:00
|
|
|
|
|
|
|
page.within(find('.deploy-keys-list', match: :first)) do
|
|
|
|
expect(page).to have_content('new-title')
|
|
|
|
end
|
2017-01-03 03:18:48 -05:00
|
|
|
end
|
2017-03-31 08:54:38 -04:00
|
|
|
end
|
2016-12-16 07:30:17 -05:00
|
|
|
|
2017-03-31 08:54:38 -04:00
|
|
|
describe 'remove an existing deploy key' do
|
|
|
|
before do
|
|
|
|
visit admin_deploy_keys_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'removes an existing deploy key' do
|
|
|
|
find('tr', text: deploy_key.title).click_link('Remove')
|
|
|
|
|
|
|
|
expect(current_path).to eq admin_deploy_keys_path
|
|
|
|
page.within(find('.deploy-keys-list', match: :first)) do
|
|
|
|
expect(page).not_to have_content(deploy_key.title)
|
|
|
|
end
|
2017-01-03 03:18:48 -05:00
|
|
|
end
|
2016-12-16 07:30:17 -05:00
|
|
|
end
|
|
|
|
end
|