debian-mirror-gitlab/spec/features/admin/admin_deploy_keys_spec.rb

78 lines
2.1 KiB
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
RSpec.describe 'admin deploy keys' do
2017-08-17 22:00:37 +05:30
let!(:deploy_key) { create(:deploy_key, public: true) }
let!(:another_deploy_key) { create(:another_deploy_key, public: true) }
before do
2017-09-10 17:25:29 +05:30
sign_in(create(:admin))
2017-08-17 22:00:37 +05:30
end
it 'show all public deploy keys' do
visit admin_deploy_keys_path
2017-09-10 17:25:29 +05:30
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
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
describe 'create a new deploy key' do
let(:new_ssh_key) { attributes_for(:key)[:key] }
2017-08-17 22:00:37 +05:30
before do
visit admin_deploy_keys_path
click_link 'New deploy key'
end
2017-09-10 17:25:29 +05:30
it 'creates a new deploy key' do
fill_in 'deploy_key_title', with: 'laptop'
fill_in 'deploy_key_key', with: new_ssh_key
check 'deploy_key_can_push'
2017-08-17 22:00:37 +05:30
click_button 'Create'
2017-09-10 17:25:29 +05:30
expect(current_path).to eq admin_deploy_keys_path
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
page.within(find('.deploy-keys-list', match: :first)) do
expect(page).to have_content('laptop')
expect(page).to have_content('Yes')
end
end
end
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
describe 'update an existing deploy key' do
before do
visit admin_deploy_keys_path
find('tr', text: deploy_key.title).click_link('Edit')
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
it 'updates an existing deploy key' do
fill_in 'deploy_key_title', with: 'new-title'
check 'deploy_key_can_push'
click_button 'Save changes'
2017-08-17 22:00:37 +05:30
expect(current_path).to eq admin_deploy_keys_path
2017-09-10 17:25:29 +05:30
page.within(find('.deploy-keys-list', match: :first)) do
expect(page).to have_content('new-title')
expect(page).to have_content('Yes')
end
2017-08-17 22:00:37 +05:30
end
2017-09-10 17:25:29 +05:30
end
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
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-08-17 22:00:37 +05:30
end
end
end