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

protected_branches_access_control_ce_shared_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: 2d3f194971620eb8b175415957e0c7184ff5791e (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
# frozen_string_literal: true

RSpec.shared_examples "protected branches > access control > CE" do
  let(:no_one) { ProtectedRef::AccessLevel.humanize(::Gitlab::Access::NO_ACCESS) }

  ProtectedRef::AccessLevel.human_access_levels.each do |(access_type_id, access_type_name)|
    it "allows creating protected branches that #{access_type_name} can push to" do
      visit project_protected_branches_path(project)

      set_protected_branch_name('master')
      set_allowed_to('merge', no_one)
      set_allowed_to('push', access_type_name)
      click_on_protect

      expect(ProtectedBranch.count).to eq(1)
      expect(ProtectedBranch.last.push_access_levels.map(&:access_level)).to eq([access_type_id])
    end

    it "allows creating protected branches that #{access_type_name} can merge to" do
      visit project_protected_branches_path(project)

      set_protected_branch_name('master')
      set_allowed_to('merge', access_type_name)
      set_allowed_to('push', no_one)
      click_on_protect

      expect(ProtectedBranch.count).to eq(1)
      expect(ProtectedBranch.last.merge_access_levels.map(&:access_level)).to eq([access_type_id])
    end

    it "allows updating protected branches so that #{access_type_name} can push to them" do
      visit project_protected_branches_path(project)

      set_protected_branch_name('master')
      set_allowed_to('merge', no_one)
      set_allowed_to('push', no_one)
      click_on_protect

      expect(ProtectedBranch.count).to eq(1)

      within(".protected-branches-list") do
        within_select(".js-allowed-to-push") do
          click_on(access_type_name)
        end
      end

      wait_for_requests

      expect(ProtectedBranch.last.push_access_levels.map(&:access_level)).to include(access_type_id)
    end

    it "allows updating protected branches so that #{access_type_name} can merge to them" do
      visit project_protected_branches_path(project)

      set_protected_branch_name('master')
      set_allowed_to('merge', no_one)
      set_allowed_to('push', no_one)
      click_on_protect

      expect(ProtectedBranch.count).to eq(1)

      within(".protected-branches-list") do
        within_select(".js-allowed-to-merge") do
          click_on(access_type_name)
        end
      end

      wait_for_requests

      expect(ProtectedBranch.last.merge_access_levels.map(&:access_level)).to include(access_type_id)
    end
  end
end