diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 07:08:36 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 07:08:36 +0000 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /spec/support/shared_examples/features/protected_branches_with_deploy_keys_examples.rb | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) | |
download | gitlab-ce-48aff82709769b098321c738f3444b9bdaa694c6.tar.gz |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'spec/support/shared_examples/features/protected_branches_with_deploy_keys_examples.rb')
-rw-r--r-- | spec/support/shared_examples/features/protected_branches_with_deploy_keys_examples.rb | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/spec/support/shared_examples/features/protected_branches_with_deploy_keys_examples.rb b/spec/support/shared_examples/features/protected_branches_with_deploy_keys_examples.rb new file mode 100644 index 00000000000..a2d2143271c --- /dev/null +++ b/spec/support/shared_examples/features/protected_branches_with_deploy_keys_examples.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'when the deploy_keys_on_protected_branches FF is turned on' do + before do + stub_feature_flags(deploy_keys_on_protected_branches: true) + project.add_maintainer(user) + sign_in(user) + end + + let(:dropdown_sections_minus_deploy_keys) { all_dropdown_sections - ['Deploy Keys'] } + + context 'when deploy keys are enabled to this project' do + let!(:deploy_key_1) { create(:deploy_key, title: 'title 1', projects: [project]) } + let!(:deploy_key_2) { create(:deploy_key, title: 'title 2', projects: [project]) } + + context 'when only one deploy key can push' do + before do + deploy_key_1.deploy_keys_projects.first.update!(can_push: true) + end + + it "shows all dropdown sections in the 'Allowed to push' main dropdown, with only one deploy key" do + visit project_protected_branches_path(project) + + find(".js-allowed-to-push").click + wait_for_requests + + within('.qa-allowed-to-push-dropdown') do + dropdown_headers = page.all('.dropdown-header').map(&:text) + + expect(dropdown_headers).to contain_exactly(*all_dropdown_sections) + expect(page).to have_content('title 1') + expect(page).not_to have_content('title 2') + end + end + + it "shows all sections but not deploy keys in the 'Allowed to merge' main dropdown" do + visit project_protected_branches_path(project) + + find(".js-allowed-to-merge").click + wait_for_requests + + within('.qa-allowed-to-merge-dropdown') do + dropdown_headers = page.all('.dropdown-header').map(&:text) + + expect(dropdown_headers).to contain_exactly(*dropdown_sections_minus_deploy_keys) + end + end + + it "shows all sections in the 'Allowed to push' update dropdown" do + create(:protected_branch, :no_one_can_push, project: project, name: 'master') + + visit project_protected_branches_path(project) + + within(".js-protected-branch-edit-form") do + find(".js-allowed-to-push").click + wait_for_requests + + dropdown_headers = page.all('.dropdown-header').map(&:text) + + expect(dropdown_headers).to contain_exactly(*all_dropdown_sections) + end + end + end + + context 'when no deploy key can push' do + it "just shows all sections but not deploy keys in the 'Allowed to push' dropdown" do + visit project_protected_branches_path(project) + + find(".js-allowed-to-push").click + wait_for_requests + + within('.qa-allowed-to-push-dropdown') do + dropdown_headers = page.all('.dropdown-header').map(&:text) + + expect(dropdown_headers).to contain_exactly(*dropdown_sections_minus_deploy_keys) + end + end + + it "just shows all sections but not deploy keys in the 'Allowed to push' update dropdown" do + create(:protected_branch, :no_one_can_push, project: project, name: 'master') + + visit project_protected_branches_path(project) + + within(".js-protected-branch-edit-form") do + find(".js-allowed-to-push").click + wait_for_requests + + dropdown_headers = page.all('.dropdown-header').map(&:text) + + expect(dropdown_headers).to contain_exactly(*dropdown_sections_minus_deploy_keys) + end + end + end + end +end |