Welcome to mirror list, hosted at ThFree Co, Russian Federation.

protected_branches_with_deploy_keys_examples.rb « features « shared_examples « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 14142793a0d04d004aedb127fe5a2905c5ae8e53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# frozen_string_literal: true

RSpec.shared_examples 'Deploy keys with protected branches' do
  before do
    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 # rubocop:disable QA/SelectorUsage
          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 # rubocop:disable QA/SelectorUsage
          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 # rubocop:disable QA/SelectorUsage
          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