2016-09-02 11:55:16 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2016-10-02 11:00:41 -04:00
|
|
|
feature 'Profile > SSH Keys', feature: true do
|
2016-09-02 11:55:16 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
login_as(user)
|
|
|
|
end
|
|
|
|
|
2016-10-02 11:00:41 -04:00
|
|
|
describe 'User adds a key' do
|
|
|
|
before do
|
|
|
|
visit profile_keys_path
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'auto-populates the title', js: true do
|
2016-09-02 11:55:16 -04:00
|
|
|
fill_in('Key', with: attributes_for(:key).fetch(:key))
|
|
|
|
|
2017-02-23 12:48:44 -05:00
|
|
|
expect(page).to have_field("Title", with: "dummy@gitlab.com")
|
2016-09-02 11:55:16 -04:00
|
|
|
end
|
2016-10-02 11:00:41 -04:00
|
|
|
|
|
|
|
scenario 'saves the new key' do
|
|
|
|
attrs = attributes_for(:key)
|
|
|
|
|
|
|
|
fill_in('Key', with: attrs[:key])
|
|
|
|
fill_in('Title', with: attrs[:title])
|
|
|
|
click_button('Add key')
|
|
|
|
|
|
|
|
expect(page).to have_content("Title: #{attrs[:title]}")
|
|
|
|
expect(page).to have_content(attrs[:key])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'User sees their keys' do
|
|
|
|
key = create(:key, user: user)
|
|
|
|
visit profile_keys_path
|
|
|
|
|
|
|
|
expect(page).to have_content(key.title)
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'User removes a key via the key index' do
|
|
|
|
create(:key, user: user)
|
|
|
|
visit profile_keys_path
|
|
|
|
|
|
|
|
click_link('Remove')
|
|
|
|
|
|
|
|
expect(page).to have_content('Your SSH keys (0)')
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'User removes a key via its details page' do
|
|
|
|
key = create(:key, user: user)
|
|
|
|
visit profile_key_path(key)
|
|
|
|
|
|
|
|
click_link('Remove')
|
|
|
|
|
|
|
|
expect(page).to have_content('Your SSH keys (0)')
|
2016-09-02 11:55:16 -04:00
|
|
|
end
|
|
|
|
end
|