diff --git a/app/assets/stylesheets/pages/projects.scss b/app/assets/stylesheets/pages/projects.scss index 8c0a0c766b24ca84234b8ea15266e64f4c4ff792..71936f3733326b2c06acf4128641bf34fca2298f 100644 --- a/app/assets/stylesheets/pages/projects.scss +++ b/app/assets/stylesheets/pages/projects.scss @@ -493,31 +493,6 @@ } } -.protected-branches-list { - margin-bottom: 32px; - - .settings-message { - margin: 0; - border-radius: 0 0 1px 1px; - padding: 20px 0; - border: 0; - } - - .table-bordered { - border-radius: 1px; - - th:not(:last-child), - td:not(:last-child) { - border-right: solid 1px transparent; - } - } - - .flash-container { - padding: 0; - } -} - - .compare-revision-cards { @media (max-width: $breakpoint-lg) { .swap-button { diff --git a/app/views/protected_branches/shared/_branches_list.html.haml b/app/views/protected_branches/shared/_branches_list.html.haml index ed2d420ffcd98576edfa344d80c8fc9a9f5330bf..1edec3082835ea905fdc96d9d12764d0d9ab6e04 100644 --- a/app/views/protected_branches/shared/_branches_list.html.haml +++ b/app/views/protected_branches/shared/_branches_list.html.haml @@ -1,12 +1,10 @@ .protected-branches-list.js-protected-branches-list{ data: { testid: 'protected-branches-list' } } - if @protected_branches.empty? - .card-header.bg-white - = s_("ProtectedBranch|Protected branch (%{protected_branches_count})") % { protected_branches_count: 0 } - %p.settings-message.text-center - = s_("ProtectedBranch|There are currently no protected branches, protect a branch with the form above.") + %p.gl-new-card-empty.gl-px-5.gl-py-4.js-toggle-content + = s_("ProtectedBranch|There are currently no protected branches, to protect a branch start by creating a new one above.") - else .flash-container - %table.table.table-bordered + %table.table.b-table.gl-table.b-table-stacked-md %colgroup %col{ width: "30%" } %col{ width: "20%" } @@ -34,5 +32,3 @@ %th %tbody = yield - - = paginate @protected_branches, theme: 'gitlab' diff --git a/app/views/protected_branches/shared/_create_protected_branch.html.haml b/app/views/protected_branches/shared/_create_protected_branch.html.haml index d97347b89dec580a4bea384c9a131b8e4b19f1e0..96e6990b080be7a0b4cb5430c2f48e604ce60d6b 100644 --- a/app/views/protected_branches/shared/_create_protected_branch.html.haml +++ b/app/views/protected_branches/shared/_create_protected_branch.html.haml @@ -1,44 +1,43 @@ = gitlab_ui_form_for [protected_branch_entity, @protected_branch], html: { class: 'new-protected-branch js-new-protected-branch' } do |f| %input{ type: 'hidden', name: 'update_section', value: 'js-protected-branches-settings' } - = render Pajamas::CardComponent.new(card_options: { class: "gl-mb-5" }) do |c| - - c.with_header do - = s_("ProtectedBranch|Protect a branch") - - c.with_body do - = form_errors(@protected_branch) - .form-group.row - = f.label :name, s_('ProtectedBranch|Branch:'), class: 'col-sm-12' - .col-sm-12 - - if protected_branch_entity.is_a?(Group) - = f.text_field :name, placeholder: 'prod*', class: 'form-control gl-w-full! gl-form-input-lg' - - else - = render partial: "protected_branches/shared/dropdown", locals: { f: f, toggle_classes: 'gl-w-full! gl-form-input-lg' } - .form-text.text-muted - - wildcards_url = help_page_url('user/project/protected_branches', anchor: 'protect-multiple-branches-with-wildcard-rules') - - wildcards_link_start = ''.html_safe % { url: wildcards_url } - - placeholders = { wildcards_link_start: wildcards_link_start, wildcards_link_end: '', code_tag_start: '', code_tag_end: '' } - - if protected_branch_entity.is_a?(Group) - = (s_("ProtectedBranch|Only %{wildcards_link_start}Wildcards%{wildcards_link_end} such as %{code_tag_start}*-stable%{code_tag_end} or %{code_tag_start}production/*%{code_tag_end} are supported.") % placeholders).html_safe - - else - = (s_("ProtectedBranch|%{wildcards_link_start}Wildcards%{wildcards_link_end} such as %{code_tag_start}*-stable%{code_tag_end} or %{code_tag_start}production/*%{code_tag_end} are supported.") % placeholders).html_safe - .form-group.row - = f.label :merge_access_levels_attributes, s_("ProtectedBranch|Allowed to merge:"), class: 'col-sm-12' - .col-sm-12 - = yield :merge_access_levels - .form-group.row - = f.label :push_access_levels_attributes, s_("ProtectedBranch|Allowed to push and merge:"), class: 'col-sm-12' - .col-sm-12 - = yield :push_access_levels - .form-group.row - = f.label :allow_force_push, s_("ProtectedBranch|Allowed to force push:"), class: 'col-sm-12' - .col-sm-12 - = render Pajamas::ToggleComponent.new(classes: 'js-force-push-toggle', - label: s_("ProtectedBranch|Allowed to force push"), - label_position: :hidden) do - - force_push_docs_url = help_page_url('topics/git/git_rebase', anchor: 'force-push') - - force_push_link_start = ''.html_safe % { url: force_push_docs_url } - = (s_("ProtectedBranch|Allow all users with push access to %{tag_start}force push%{tag_end}.") % { tag_start: force_push_link_start, tag_end: '' }).html_safe - = render_if_exists 'protected_branches/ee/code_owner_approval_form', f: f, protected_branch_entity: protected_branch_entity - - c.with_footer do - = f.submit s_('ProtectedBranch|Protect'), disabled: true, data: { qa_selector: 'protect_button' }, pajamas_button: true - .js-alert-protected-branch-created-container.gl-mb-5 + = form_errors(@protected_branch) + + %h4.gl-mt-0= s_("ProtectedBranch|Protect a branch") + + .form-group.row + = f.label :name, s_('ProtectedBranch|Branch:'), class: 'col-sm-12' + .col-sm-12 + - if protected_branch_entity.is_a?(Group) + = f.text_field :name, placeholder: 'prod*', class: 'form-control gl-w-full! gl-form-input-lg' + - else + = render partial: "protected_branches/shared/dropdown", locals: { f: f, toggle_classes: 'gl-w-full! gl-form-input-lg' } + .form-text.text-muted + - wildcards_url = help_page_url('user/project/protected_branches', anchor: 'protect-multiple-branches-with-wildcard-rules') + - wildcards_link_start = ''.html_safe % { url: wildcards_url } + - placeholders = { wildcards_link_start: wildcards_link_start, wildcards_link_end: '', code_tag_start: '', code_tag_end: '' } + - if protected_branch_entity.is_a?(Group) + = (s_("ProtectedBranch|Only %{wildcards_link_start}Wildcards%{wildcards_link_end} such as %{code_tag_start}*-stable%{code_tag_end} or %{code_tag_start}production/*%{code_tag_end} are supported.") % placeholders).html_safe + - else + = (s_("ProtectedBranch|%{wildcards_link_start}Wildcards%{wildcards_link_end} such as %{code_tag_start}*-stable%{code_tag_end} or %{code_tag_start}production/*%{code_tag_end} are supported.") % placeholders).html_safe + .form-group.row + = f.label :merge_access_levels_attributes, s_("ProtectedBranch|Allowed to merge:"), class: 'col-sm-12' + .col-sm-12 + = yield :merge_access_levels + .form-group.row + = f.label :push_access_levels_attributes, s_("ProtectedBranch|Allowed to push and merge:"), class: 'col-sm-12' + .col-sm-12 + = yield :push_access_levels + .form-group.row + = f.label :allow_force_push, s_("ProtectedBranch|Allowed to force push:"), class: 'col-sm-12' + .col-sm-12 + = render Pajamas::ToggleComponent.new(classes: 'js-force-push-toggle', + label: s_("ProtectedBranch|Allowed to force push"), + label_position: :hidden) do + - force_push_docs_url = help_page_url('topics/git/git_rebase', anchor: 'force-push') + - force_push_link_start = ''.html_safe % { url: force_push_docs_url } + = (s_("ProtectedBranch|Allow all users with push access to %{tag_start}force push%{tag_end}.") % { tag_start: force_push_link_start, tag_end: '' }).html_safe + = render_if_exists 'protected_branches/ee/code_owner_approval_form', f: f, protected_branch_entity: protected_branch_entity + = f.submit s_('ProtectedBranch|Protect'), disabled: true, data: { qa_selector: 'protect_button' }, pajamas_button: true + = render Pajamas::ButtonComponent.new(button_options: { type: 'reset', class: 'gl-ml-2 js-toggle-button' }) do + = _('Cancel') diff --git a/app/views/protected_branches/shared/_index.html.haml b/app/views/protected_branches/shared/_index.html.haml index d0e21e38429cad8bb1d16371172a5bc7234fd054..03b842189a890617ad5599a8c7bf8540fea697ed 100644 --- a/app/views/protected_branches/shared/_index.html.haml +++ b/app/views/protected_branches/shared/_index.html.haml @@ -7,15 +7,31 @@ = s_("ProtectedBranch|Protected branches") = render Pajamas::ButtonComponent.new(button_options: { class: 'js-settings-toggle' }) do = expanded ? _('Collapse') : _('Expand') - %p + %p.gl-text-secondary.gl-mb-0 = s_("ProtectedBranch|Keep stable branches secure and force developers to use merge requests.") = link_to s_("ProtectedBranch|What are protected branches?"), help_page_path("user/project/protected_branches") .settings-content - %p - = s_("ProtectedBranch|By default, protected branches restrict who can modify the branch.") - = link_to s_("ProtectedBranch|Learn more."), help_page_path("user/project/protected_branches", anchor: "who-can-modify-a-protected-branch") + .js-alert-protected-branch-created-container.gl-mt-5 - - if can_admin_entity - = content_for :create_protected_branch + = render Pajamas::CardComponent.new(card_options: { class: 'gl-new-card js-toggle-container' }, header_options: { class: 'gl-new-card-header gl-flex-direction-column' }, body_options: { class: 'gl-new-card-body gl-px-0' }) do |c| + - c.with_header do + .gl-new-card-title-wrapper.gl-justify-content-space-between + %h3.gl-new-card-title + = s_("ProtectedBranch|Protected branches") + .gl-new-card-count + = sprite_icon('branch', css_class: 'gl-mr-2') + %span= @protected_branches.size + .gl-new-card-actions + = render Pajamas::ButtonComponent.new(size: :small, button_options: { class: 'js-toggle-button js-toggle-content', data: { testid: 'add-new-token-button' } }) do + = _('Add protected branch') + .gl-new-card-description.gl-mt-2.gl-sm-mt-0 + = s_("ProtectedBranch|By default, protected branches restrict who can modify the branch.") + = link_to s_("ProtectedBranch|Learn more."), help_page_path("user/project/protected_branches", anchor: "who-can-modify-a-protected-branch") + - c.with_body do + - if can_admin_entity + .gl-new-card-add-form.gl-m-3.gl-display-none.js-toggle-content + = content_for :create_protected_branch - = content_for :branches_list + = content_for :branches_list + + = paginate @protected_branches, theme: 'gitlab' diff --git a/app/views/protected_branches/shared/_protected_branch.html.haml b/app/views/protected_branches/shared/_protected_branch.html.haml index 69969b7f8485595c9376382ca26376be2b9628c2..93c84e67d817d5a4f49139bb54dc958d566f6c24 100644 --- a/app/views/protected_branches/shared/_protected_branch.html.haml +++ b/app/views/protected_branches/shared/_protected_branch.html.haml @@ -3,14 +3,14 @@ - protected_branch_test_type = protected_branch.project_level? ? 'project-level' : 'group-level' %tr.js-protected-branch-edit-form{ data: { url: url, testid: 'protected-branch', test_type: protected_branch_test_type } } - %td - %span.ref-name= protected_branch.name + %td{ class: 'gl-vertical-align-middle!', data: { label: s_("ProtectedBranch|Branch") } } + %div + %span.ref-name= protected_branch.name - - if protected_branch.project_level? - - if protected_branch_entity.root_ref?(protected_branch.name) - = gl_badge_tag s_('ProtectedBranch|default'), variant: :info + - if protected_branch.project_level? + - if protected_branch_entity.root_ref?(protected_branch.name) + = gl_badge_tag s_('ProtectedBranch|default'), variant: :info - %div - if protected_branch.wildcard? - matching_branches = protected_branch.matching(repository.branch_names) = link_to pluralize(matching_branches.count, "matching branch"), namespace_project_protected_branch_path(@project.namespace, @project, protected_branch) @@ -22,9 +22,9 @@ = render_if_exists 'protected_branches/ee/code_owner_approval_table', can_update: local_assigns[:can_update], protected_branch: protected_branch, protected_branch_entity: protected_branch_entity - if can_admin_entity - %td.text-right{ data: { testid: 'protected-branch-action' } } + %td.text-right{ data: { label: _('Actions'), testid: 'protected-branch-action' } } - if local_assigns[:is_inherited] %span.has-tooltip{ data: { container: 'body' }, title: s_('ProtectedBranch|Inherited - This setting can be changed at the group level'), 'aria-hidden': 'true' } = sprite_icon 'lock' - else - = link_button_to s_('ProtectedBranch|Unprotect'), [protected_branch_entity, protected_branch, { update_section: 'js-protected-branches-settings' }], disabled: local_assigns[:disabled], aria: { label: s_('ProtectedBranch|Unprotect branch') }, data: { confirm: s_('ProtectedBranch|Branch will be writable for developers. Are you sure?'), confirm_btn_variant: 'danger' }, method: :delete, variant: :danger, size: :small + = link_button_to s_('ProtectedBranch|Unprotect'), [protected_branch_entity, protected_branch, { update_section: 'js-protected-branches-settings' }], disabled: local_assigns[:disabled], aria: { label: s_('ProtectedBranch|Unprotect branch') }, data: { confirm: s_('ProtectedBranch|Branch will be writable for developers. Are you sure?'), confirm_btn_variant: 'danger' }, method: :delete, variant: :danger, category: :secondary, size: :small diff --git a/ee/app/views/protected_branches/ee/_code_owner_approval_table.html.haml b/ee/app/views/protected_branches/ee/_code_owner_approval_table.html.haml index e3c2d49f4656515d74f2dd7e21d450f44eca68c7..43f04258982e7f2bc83d7dbd18f0d1745fdf92a3 100644 --- a/ee/app/views/protected_branches/ee/_code_owner_approval_table.html.haml +++ b/ee/app/views/protected_branches/ee/_code_owner_approval_table.html.haml @@ -1,5 +1,5 @@ - if protected_branch_entity.feature_available?(:code_owner_approval_required) - %td + %td{ data: { label: s_("ProtectedBranch|Code owner approval") } } = render Pajamas::ToggleComponent.new(classes: 'js-code-owner-toggle gl-mr-5', label: s_("ProtectedBranch|Toggle code owner approval"), is_checked: protected_branch.code_owner_approval_required, diff --git a/ee/app/views/protected_branches/ee/_protected_branch_access_summary.html.haml b/ee/app/views/protected_branches/ee/_protected_branch_access_summary.html.haml index 64515e14096b036a8147b0bf3993bb1af2873739..9fbd20212483ebf7903073b0d7e81d7ac2fe1a5b 100644 --- a/ee/app/views/protected_branches/ee/_protected_branch_access_summary.html.haml +++ b/ee/app/views/protected_branches/ee/_protected_branch_access_summary.html.haml @@ -1,12 +1,12 @@ - cannot_unprotect = !local_assigns[:can_update] -%td +%td{ data: { label: s_("ProtectedBranch|Allowed to merge") } } = render partial: 'projects/settings/ee/access_level_dropdown', locals: { protected_branch: protected_branch, access_levels: protected_branch.merge_access_levels, level_frequencies: access_level_frequencies(protected_branch.merge_access_levels), input_basic_name: 'merge_access_levels', disabled: cannot_unprotect, toggle_class: 'js-allowed-to-merge', testid: "protected-branch-allowed-to-merge" } -%td +%td{ data: { label: s_("ProtectedBranch|Allowed to push and merge") } } = render partial: 'projects/settings/ee/access_level_dropdown', locals: { protected_branch: protected_branch, access_levels: protected_branch.push_access_levels, level_frequencies: access_level_frequencies(protected_branch.push_access_levels), input_basic_name: 'push_access_levels', disabled: cannot_unprotect, toggle_class: 'js-allowed-to-push', testid: 'protected-branch-allowed-to-push' } -%td +%td{ data: { label: s_("ProtectedBranch|Allowed to force push") } } = render Pajamas::ToggleComponent.new(classes: 'js-force-push-toggle', data: { testid: 'protected-branch-force-push-toggle' }, label: s_("ProtectedBranch|Toggle allowed to force push"), diff --git a/ee/spec/features/group_protected_branches_spec.rb b/ee/spec/features/group_protected_branches_spec.rb index ba43907a70ac5ec66d378c7c02892437202d3dbf..9677ac2e36bbec9290281962eaf21eec9049c742 100644 --- a/ee/spec/features/group_protected_branches_spec.rb +++ b/ee/spec/features/group_protected_branches_spec.rb @@ -86,6 +86,7 @@ let(:license_code_owner_approval_required) { false } it 'has no `code_owner_approval` form field' do + click_button 'Add protected branch' expect(new_container).not_to have_css('.js-code-owner-toggle') expect(list_container).not_to have_css('.js-code-owner-toggle') end @@ -103,11 +104,11 @@ let(:push_access) { 'No one' } it 'created successfully' do + click_button 'Add protected branch' branch_input.fill_in with: branch_name - update_protected_branch_form(real_time_request: false) - click_on 'Protect' + wait_for_requests protected_branch = group.protected_branches.last diff --git a/ee/spec/features/groups/settings/repository_spec.rb b/ee/spec/features/groups/settings/repository_spec.rb index ebe9966b799e63aba5f1dabd4e4c2da0e7ec7c6b..1d7e0350ad1b1e9f5d7fead62ab6cd81ba11bded 100644 --- a/ee/spec/features/groups/settings/repository_spec.rb +++ b/ee/spec/features/groups/settings/repository_spec.rb @@ -29,6 +29,7 @@ it 'does not show users in the access levels dropdown' do within('#js-protected-branches-settings') do + click_button 'Add protected branch' find('.dropdown-menu-toggle.js-allowed-to-merge').click wait_for_all_requests diff --git a/ee/spec/features/protected_branches_spec.rb b/ee/spec/features/protected_branches_spec.rb index cd3e9f6f247e47f1b55787ee49c1f123b0c65b4a..520a28cdd5590b181594740ce894e88f52276ddc 100644 --- a/ee/spec/features/protected_branches_spec.rb +++ b/ee/spec/features/protected_branches_spec.rb @@ -34,6 +34,7 @@ end def fill_in_form(branch_name) + click_button 'Add protected branch' branch_input.click click_on branch_name @@ -52,6 +53,7 @@ def submit_form end it 'has code owner toggle' do + click_button 'Add protected branch' expect(page).to have_content("Require approval from code owners") expect(code_owner_toggle[:class]).to include("is-checked") end diff --git a/ee/spec/support/shared_examples/features/protected_branches_access_control_shared_examples.rb b/ee/spec/support/shared_examples/features/protected_branches_access_control_shared_examples.rb index c52f71d5fda30bee102c1c6ae243f52526fa249e..22c8e5a259a5957198e9f432f66279028988ce19 100644 --- a/ee/spec/support/shared_examples/features/protected_branches_access_control_shared_examples.rb +++ b/ee/spec/support/shared_examples/features/protected_branches_access_control_shared_examples.rb @@ -24,6 +24,7 @@ it "allows creating protected branches that roles, users, and groups can #{git_operation} to" do visit project_protected_branches_path(project) + show_add_form set_protected_branch_name('master') set_allowed_to(git_operation, roles.values) set_allowed_to(git_operation, groups.map(&:name)) @@ -46,6 +47,8 @@ it "allows updating protected branches so that roles and users can #{git_operation} to it" do visit project_protected_branches_path(project) + + show_add_form set_protected_branch_name('master') set_allowed_to('merge') set_allowed_to('push') @@ -72,6 +75,8 @@ it "allows updating protected branches so that roles and users cannot #{git_operation} to it" do visit project_protected_branches_path(project) + + show_add_form set_protected_branch_name('master') set_allowed_to(git_operation, roles.values) @@ -100,6 +105,7 @@ visit project_protected_branches_path(project) # Create Protected Branch + show_add_form set_protected_branch_name('master') set_allowed_to(git_operation, roles.values) set_allowed_to(other_git_operation) @@ -142,6 +148,8 @@ context 'When updating a protected branch' do it 'discards other roles when choosing "No one"' do visit project_protected_branches_path(project) + + show_add_form set_protected_branch_name('fix') set_allowed_to('merge') set_allowed_to('push', roles.values) @@ -163,6 +171,8 @@ context 'When creating a protected branch' do it 'discards other roles when choosing "No one"' do visit project_protected_branches_path(project) + + show_add_form set_protected_branch_name('master') set_allowed_to('merge') set_allowed_to('push', roles.values) diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 952e3e6e6ee097f73d53ad1978e3d7c66ad5aa88..9fa1115061e25d2d12888ae9c10204e6d67fae89 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -2935,6 +2935,9 @@ msgstr "" msgid "Add projects" msgstr "" +msgid "Add protected branch" +msgstr "" + msgid "Add reaction" msgstr "" @@ -37953,9 +37956,6 @@ msgstr "" msgid "ProtectedBranch|Protect a branch" msgstr "" -msgid "ProtectedBranch|Protected branch (%{protected_branches_count})" -msgstr "" - msgid "ProtectedBranch|Protected branches" msgstr "" @@ -37974,7 +37974,7 @@ msgstr "" msgid "ProtectedBranch|Tag" msgstr "" -msgid "ProtectedBranch|There are currently no protected branches, protect a branch with the form above." +msgid "ProtectedBranch|There are currently no protected branches, to protect a branch start by creating a new one above." msgstr "" msgid "ProtectedBranch|Toggle allowed to force push" diff --git a/spec/features/protected_branches_spec.rb b/spec/features/protected_branches_spec.rb index 9244cafbc0b77ddd91b451abd8b19d309eb356a5..ee5d92b7cdb75c1b221d8c96dddd5b30f5198d98 100644 --- a/spec/features/protected_branches_spec.rb +++ b/spec/features/protected_branches_spec.rb @@ -40,6 +40,8 @@ it 'allows to create a protected branch with name containing HTML tags' do visit project_protected_branches_path(project) + + show_add_form set_defaults set_protected_branch_name('foobar<\b>') click_on "Protect" @@ -89,6 +91,8 @@ describe "explicit protected branches" do it "allows creating explicit protected branches" do visit project_protected_branches_path(project) + + show_add_form set_defaults set_protected_branch_name('some->branch') click_on "Protect" @@ -100,6 +104,8 @@ it "shows success alert once protected branch is created" do visit project_protected_branches_path(project) + + show_add_form set_defaults set_protected_branch_name('some->branch') click_on "Protect" @@ -112,6 +118,8 @@ project.repository.add_branch(admin, 'some-branch', commit.id) visit project_protected_branches_path(project) + + show_add_form set_defaults set_protected_branch_name('some-branch') click_on "Protect" @@ -124,6 +132,8 @@ it "displays an error message if the named branch does not exist" do visit project_protected_branches_path(project) + + show_add_form set_defaults set_protected_branch_name('some-branch') click_on "Protect" @@ -135,6 +145,8 @@ describe "wildcard protected branches" do it "allows creating protected branches with a wildcard" do visit project_protected_branches_path(project) + + show_add_form set_defaults set_protected_branch_name('*-stable') click_on "Protect" @@ -149,6 +161,8 @@ project.repository.add_branch(admin, 'staging-stable', 'master') visit project_protected_branches_path(project) + + show_add_form set_defaults set_protected_branch_name('*-stable') click_on "Protect" @@ -164,6 +178,8 @@ project.repository.add_branch(admin, 'development', 'master') visit project_protected_branches_path(project) + + show_add_form set_protected_branch_name('*-stable') set_defaults click_on "Protect" diff --git a/spec/support/protected_branch_helpers.rb b/spec/support/protected_branch_helpers.rb index d983d03fd2ea4b51024e5d5e8830ed8518579376..576275e9d1d1bf85744050f1ee9ddbcf444f4ce9 100644 --- a/spec/support/protected_branch_helpers.rb +++ b/spec/support/protected_branch_helpers.rb @@ -9,6 +9,10 @@ def set_allowed_to(operation, option = 'Maintainers', form: '.js-new-protected-b end end + def show_add_form + click_button 'Add protected branch' + end + def set_protected_branch_name(branch_name) find('.js-protected-branch-select').click find('.dropdown-input-field').set(branch_name) diff --git a/spec/support/shared_examples/features/protected_branches_access_control_ce_shared_examples.rb b/spec/support/shared_examples/features/protected_branches_access_control_ce_shared_examples.rb index 2d3f194971620eb8b175415957e0c7184ff5791e..fb882ef8a239da2d52def3f98f5de4780b2d0f3b 100644 --- a/spec/support/shared_examples/features/protected_branches_access_control_ce_shared_examples.rb +++ b/spec/support/shared_examples/features/protected_branches_access_control_ce_shared_examples.rb @@ -7,6 +7,7 @@ it "allows creating protected branches that #{access_type_name} can push to" do visit project_protected_branches_path(project) + show_add_form set_protected_branch_name('master') set_allowed_to('merge', no_one) set_allowed_to('push', access_type_name) @@ -19,6 +20,7 @@ it "allows creating protected branches that #{access_type_name} can merge to" do visit project_protected_branches_path(project) + show_add_form set_protected_branch_name('master') set_allowed_to('merge', access_type_name) set_allowed_to('push', no_one) @@ -31,6 +33,7 @@ it "allows updating protected branches so that #{access_type_name} can push to them" do visit project_protected_branches_path(project) + show_add_form set_protected_branch_name('master') set_allowed_to('merge', no_one) set_allowed_to('push', no_one) @@ -52,6 +55,7 @@ it "allows updating protected branches so that #{access_type_name} can merge to them" do visit project_protected_branches_path(project) + show_add_form set_protected_branch_name('master') set_allowed_to('merge', no_one) set_allowed_to('push', no_one) 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 index 90b0e60022873c5adea3e20bc322977ca726fdab..a15ee47de347bb4ec96e12d394ee8446bd8196c4 100644 --- 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 @@ -20,6 +20,7 @@ it "shows all dropdown sections in the 'Allowed to push' main dropdown, with only one deploy key" do visit project_protected_branches_path(project) + click_button 'Add protected branch' find(".js-allowed-to-push").click wait_for_requests @@ -35,6 +36,7 @@ it "shows all sections but not deploy keys in the 'Allowed to merge' main dropdown" do visit project_protected_branches_path(project) + click_button 'Add protected branch' find(".js-allowed-to-merge").click wait_for_requests @@ -65,6 +67,7 @@ it "just shows all sections but not deploy keys in the 'Allowed to push' dropdown" do visit project_protected_branches_path(project) + click_button 'Add protected branch' find(".js-allowed-to-push").click wait_for_requests