summaryrefslogtreecommitdiff
path: root/qa/qa/page/project/settings/protected_branches.rb
blob: 399a49d2420c8007c205c339613ecaa1ed747b98 (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
module QA
  module Page
    module Project
      module Settings
        class ProtectedBranches < Page::Base
          view 'app/views/projects/protected_branches/shared/_dropdown.html.haml' do
            element :protected_branch_select
            element :protected_branch_dropdown
          end

          view 'app/views/projects/protected_branches/_create_protected_branch.html.haml' do
            element :allowed_to_push_select
            element :allowed_to_push_dropdown
            element :allowed_to_merge_select
            element :allowed_to_merge_dropdown
          end

          view 'app/views/projects/protected_branches/_update_protected_branch.html.haml' do
            element :allowed_to_merge
          end

          view 'app/views/projects/protected_branches/shared/_branches_list.html.haml' do
            element :protected_branches_list
          end

          def select_branch(branch_name)
            click_element :protected_branch_select

            within_element(:protected_branch_dropdown) do
              click_on branch_name
            end
          end

          def allow_no_one_to_push
            go_to_allow(:push, 'No one')
          end

          def allow_devs_and_maintainers_to_push
            go_to_allow(:push, 'Developers + Maintainers')
          end

          # @deprecated
          alias_method :allow_devs_and_masters_to_push, :allow_devs_and_maintainers_to_push

          def allow_no_one_to_merge
            go_to_allow(:merge, 'No one')
          end

          def allow_devs_and_maintainers_to_merge
            go_to_allow(:merge, 'Developers + Maintainers')
          end

          # @deprecated
          alias_method :allow_devs_and_masters_to_merge, :allow_devs_and_maintainers_to_merge

          def protect_branch
            click_on 'Protect'
          end

          private

          def go_to_allow(action, text)
            click_element :"allowed_to_#{action}_select"

            within_element(:"allowed_to_#{action}_dropdown") do
              click_on text
            end
          end
        end
      end
    end
  end
end