diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-02 15:08:01 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-02 15:08:01 +0000 |
commit | b375c6c05fbd03aea33a9ee9f82e678bdaa8c3cc (patch) | |
tree | 55f2a32e5fd3d67597fc8c6cc2a01793ee15c87a /spec/features | |
parent | 988b28ec1a379d38f6ac9ed04886ee564fd447fd (diff) | |
download | gitlab-ce-b375c6c05fbd03aea33a9ee9f82e678bdaa8c3cc.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features')
4 files changed, 96 insertions, 91 deletions
diff --git a/spec/features/projects/deploy_keys_spec.rb b/spec/features/projects/deploy_keys_spec.rb index 0f3e7646673..03b7c54faf6 100644 --- a/spec/features/projects/deploy_keys_spec.rb +++ b/spec/features/projects/deploy_keys_spec.rb @@ -17,9 +17,9 @@ describe 'Project deploy keys', :js do end it 'removes association between project and deploy key' do - visit project_settings_repository_path(project) + visit project_settings_ci_cd_path(project) - page.within(find('.deploy-keys')) do + page.within(find('.qa-deploy-keys-settings')) do expect(page).to have_selector('.deploy-key', count: 1) accept_confirm { find('.ic-remove').click } diff --git a/spec/features/projects/settings/ci_cd_settings_spec.rb b/spec/features/projects/settings/ci_cd_settings_spec.rb index e69ee31e582..8b9b1ac00c3 100644 --- a/spec/features/projects/settings/ci_cd_settings_spec.rb +++ b/spec/features/projects/settings/ci_cd_settings_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper' -describe 'Projects > Settings > CI/CD settings' do - let(:project) { create(:project_empty_repo) } - let(:user) { create(:user) } - let(:role) { :maintainer } +describe 'Projects > Settings > CI / CD settings' do + let_it_be(:project) { create(:project_empty_repo) } + let_it_be(:user) { create(:user) } + let_it_be(:role) { :maintainer } context 'Deploy tokens' do let!(:deploy_token) { create(:deploy_token, projects: [project]) } @@ -21,4 +21,92 @@ describe 'Projects > Settings > CI/CD settings' do let(:entity_type) { 'project' } end end + + context 'Deploy Keys', :js do + let_it_be(:private_deploy_key) { create(:deploy_key, title: 'private_deploy_key', public: false) } + let_it_be(:public_deploy_key) { create(:another_deploy_key, title: 'public_deploy_key', public: true) } + let(:new_ssh_key) { attributes_for(:key)[:key] } + + before do + project.add_role(user, role) + sign_in(user) + end + + it 'get list of keys' do + project.deploy_keys << private_deploy_key + project.deploy_keys << public_deploy_key + + visit project_settings_ci_cd_path(project) + + expect(page).to have_content('private_deploy_key') + expect(page).to have_content('public_deploy_key') + end + + it 'add a new deploy key' do + visit project_settings_ci_cd_path(project) + + fill_in 'deploy_key_title', with: 'new_deploy_key' + fill_in 'deploy_key_key', with: new_ssh_key + check 'deploy_key_deploy_keys_projects_attributes_0_can_push' + click_button 'Add key' + + expect(page).to have_content('new_deploy_key') + expect(page).to have_content('Write access allowed') + end + + it 'edit an existing deploy key' do + project.deploy_keys << private_deploy_key + visit project_settings_ci_cd_path(project) + + find('.deploy-key', text: private_deploy_key.title).find('.ic-pencil').click + + fill_in 'deploy_key_title', with: 'updated_deploy_key' + check 'deploy_key_deploy_keys_projects_attributes_0_can_push' + click_button 'Save changes' + + expect(page).to have_content('updated_deploy_key') + expect(page).to have_content('Write access allowed') + end + + it 'edit an existing public deploy key to be writable' do + project.deploy_keys << public_deploy_key + visit project_settings_ci_cd_path(project) + + find('.deploy-key', text: public_deploy_key.title).find('.ic-pencil').click + + check 'deploy_key_deploy_keys_projects_attributes_0_can_push' + click_button 'Save changes' + + expect(page).to have_content('public_deploy_key') + expect(page).to have_content('Write access allowed') + end + + it 'edit a deploy key from projects user has access to' do + project2 = create(:project_empty_repo) + project2.add_role(user, role) + project2.deploy_keys << private_deploy_key + + visit project_settings_ci_cd_path(project) + + find('.js-deployKeys-tab-available_project_keys').click + + find('.deploy-key', text: private_deploy_key.title).find('.ic-pencil').click + + fill_in 'deploy_key_title', with: 'updated_deploy_key' + click_button 'Save changes' + + find('.js-deployKeys-tab-available_project_keys').click + + expect(page).to have_content('updated_deploy_key') + end + + it 'remove an existing deploy key' do + project.deploy_keys << private_deploy_key + visit project_settings_ci_cd_path(project) + + accept_confirm { find('.deploy-key', text: private_deploy_key.title).find('.ic-remove').click } + + expect(page).not_to have_content(private_deploy_key.title) + end + end end diff --git a/spec/features/projects/settings/repository_settings_spec.rb b/spec/features/projects/settings/repository_settings_spec.rb index d750234d9ad..9030cd6a648 100644 --- a/spec/features/projects/settings/repository_settings_spec.rb +++ b/spec/features/projects/settings/repository_settings_spec.rb @@ -25,89 +25,6 @@ describe 'Projects > Settings > Repository settings' do context 'for maintainer' do let(:role) { :maintainer } - context 'Deploy Keys', :js do - let(:private_deploy_key) { create(:deploy_key, title: 'private_deploy_key', public: false) } - let(:public_deploy_key) { create(:another_deploy_key, title: 'public_deploy_key', public: true) } - let(:new_ssh_key) { attributes_for(:key)[:key] } - - it 'get list of keys' do - project.deploy_keys << private_deploy_key - project.deploy_keys << public_deploy_key - - visit project_settings_repository_path(project) - - expect(page).to have_content('private_deploy_key') - expect(page).to have_content('public_deploy_key') - end - - it 'add a new deploy key' do - visit project_settings_repository_path(project) - - fill_in 'deploy_key_title', with: 'new_deploy_key' - fill_in 'deploy_key_key', with: new_ssh_key - check 'deploy_key_deploy_keys_projects_attributes_0_can_push' - click_button 'Add key' - - expect(page).to have_content('new_deploy_key') - expect(page).to have_content('Write access allowed') - end - - it 'edit an existing deploy key' do - project.deploy_keys << private_deploy_key - visit project_settings_repository_path(project) - - find('.deploy-key', text: private_deploy_key.title).find('.ic-pencil').click - - fill_in 'deploy_key_title', with: 'updated_deploy_key' - check 'deploy_key_deploy_keys_projects_attributes_0_can_push' - click_button 'Save changes' - - expect(page).to have_content('updated_deploy_key') - expect(page).to have_content('Write access allowed') - end - - it 'edit an existing public deploy key to be writable' do - project.deploy_keys << public_deploy_key - visit project_settings_repository_path(project) - - find('.deploy-key', text: public_deploy_key.title).find('.ic-pencil').click - - check 'deploy_key_deploy_keys_projects_attributes_0_can_push' - click_button 'Save changes' - - expect(page).to have_content('public_deploy_key') - expect(page).to have_content('Write access allowed') - end - - it 'edit a deploy key from projects user has access to' do - project2 = create(:project_empty_repo) - project2.add_role(user, role) - project2.deploy_keys << private_deploy_key - - visit project_settings_repository_path(project) - - find('.js-deployKeys-tab-available_project_keys').click - - find('.deploy-key', text: private_deploy_key.title).find('.ic-pencil').click - - fill_in 'deploy_key_title', with: 'updated_deploy_key' - click_button 'Save changes' - - find('.js-deployKeys-tab-available_project_keys').click - - expect(page).to have_content('updated_deploy_key') - end - - it 'remove an existing deploy key' do - project.deploy_keys << private_deploy_key - visit project_settings_repository_path(project) - - accept_confirm { find('.deploy-key', text: private_deploy_key.title).find('.ic-remove').click } - - expect(page).not_to have_content(private_deploy_key.title) - end - end - context 'remote mirror settings' do let(:user2) { create(:user) } diff --git a/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb b/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb index cd9299150b2..ac7788ba1fa 100644 --- a/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb +++ b/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb @@ -20,7 +20,7 @@ describe "User interacts with deploy keys", :js do click_button("Enable") expect(page).not_to have_selector(".fa-spinner") - expect(current_path).to eq(project_settings_repository_path(project)) + expect(current_path).to eq(project_settings_ci_cd_path(project)) find(".js-deployKeys-tab-enabled_keys").click @@ -96,7 +96,7 @@ describe "User interacts with deploy keys", :js do click_button("Add key") - expect(current_path).to eq(project_settings_repository_path(project)) + expect(current_path).to eq(project_settings_ci_cd_path(project)) page.within(".deploy-keys") do expect(page).to have_content(DEPLOY_KEY_TITLE) |