diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-31 12:12:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-31 12:12:13 +0300 |
commit | 6a5ef9b75d38f39cd2a6a2392fadfbd3b966b884 (patch) | |
tree | 56d7c715f2e312cb0ae47439385f2a6cba6fea5e | |
parent | 01cc900e7cc64797e39a7889032325d8c32bfe46 (diff) |
Add latest changes from gitlab-org/gitlab@master
26 files changed, 184 insertions, 161 deletions
diff --git a/app/graphql/types/packages/package_base_type.rb b/app/graphql/types/packages/package_base_type.rb index aa580d48709..5102e4ebcd5 100644 --- a/app/graphql/types/packages/package_base_type.rb +++ b/app/graphql/types/packages/package_base_type.rb @@ -10,11 +10,19 @@ module Types authorize :read_package + expose_permissions Types::PermissionTypes::Package + field :id, ::Types::GlobalIDType[::Packages::Package], null: false, description: 'ID of the package.' field :_links, Types::Packages::PackageLinksType, null: false, method: :itself, description: 'Map of links to perform actions on the package.' - field :can_destroy, GraphQL::Types::Boolean, null: false, description: 'Whether the user can destroy the package.' + field :can_destroy, GraphQL::Types::Boolean, + null: false, + deprecated: { + reason: 'Superseded by `user_permissions` field. See `Types::PermissionTypes::Package` type', + milestone: '16.6' + }, + description: 'Whether the user can destroy the package.' field :created_at, Types::TimeType, null: false, description: 'Date of creation.' field :metadata, Types::Packages::MetadataType, null: true, diff --git a/app/graphql/types/permission_types/package.rb b/app/graphql/types/permission_types/package.rb new file mode 100644 index 00000000000..debde3a1a8e --- /dev/null +++ b/app/graphql/types/permission_types/package.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Types + module PermissionTypes + class Package < BasePermissionType + graphql_name 'PackagePermissions' + + ability_field :destroy_package, + description: 'If `true`, the user can perform `destroy_package` on this resource' + end + end +end diff --git a/config/feature_flags/development/composer_use_ssh_source_urls.yml b/config/feature_flags/development/composer_use_ssh_source_urls.yml deleted file mode 100644 index d74dcdf9806..00000000000 --- a/config/feature_flags/development/composer_use_ssh_source_urls.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: composer_use_ssh_source_urls -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/119739 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/422171 -milestone: '16.4' -type: development -group: group::package registry -default_enabled: true diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md index 17c1c182e72..fc43d7b2ebf 100644 --- a/doc/api/graphql/reference/index.md +++ b/doc/api/graphql/reference/index.md @@ -22023,7 +22023,7 @@ Represents a package with pipelines in the Package Registry. | Name | Type | Description | | ---- | ---- | ----------- | | <a id="package_links"></a>`_links` | [`PackageLinks!`](#packagelinks) | Map of links to perform actions on the package. | -| <a id="packagecandestroy"></a>`canDestroy` | [`Boolean!`](#boolean) | Whether the user can destroy the package. | +| <a id="packagecandestroy"></a>`canDestroy` **{warning-solid}** | [`Boolean!`](#boolean) | **Deprecated** in 16.6. Superseded by `user_permissions` field. See `Types::PermissionTypes::Package` type. | | <a id="packagecreatedat"></a>`createdAt` | [`Time!`](#time) | Date of creation. | | <a id="packageid"></a>`id` | [`PackagesPackageID!`](#packagespackageid) | ID of the package. | | <a id="packagemetadata"></a>`metadata` | [`PackageMetadata`](#packagemetadata) | Package metadata. | @@ -22035,6 +22035,7 @@ Represents a package with pipelines in the Package Registry. | <a id="packagestatusmessage"></a>`statusMessage` | [`String`](#string) | Status message. | | <a id="packagetags"></a>`tags` | [`PackageTagConnection`](#packagetagconnection) | Package tags. (see [Connections](#connections)) | | <a id="packageupdatedat"></a>`updatedAt` | [`Time!`](#time) | Date of most recent update. | +| <a id="packageuserpermissions"></a>`userPermissions` | [`PackagePermissions!`](#packagepermissions) | Permissions for the current user on the resource. | | <a id="packageversion"></a>`version` | [`String`](#string) | Version string. | ### `PackageBase` @@ -22046,7 +22047,7 @@ Represents a package in the Package Registry. | Name | Type | Description | | ---- | ---- | ----------- | | <a id="packagebase_links"></a>`_links` | [`PackageLinks!`](#packagelinks) | Map of links to perform actions on the package. | -| <a id="packagebasecandestroy"></a>`canDestroy` | [`Boolean!`](#boolean) | Whether the user can destroy the package. | +| <a id="packagebasecandestroy"></a>`canDestroy` **{warning-solid}** | [`Boolean!`](#boolean) | **Deprecated** in 16.6. Superseded by `user_permissions` field. See `Types::PermissionTypes::Package` type. | | <a id="packagebasecreatedat"></a>`createdAt` | [`Time!`](#time) | Date of creation. | | <a id="packagebaseid"></a>`id` | [`PackagesPackageID!`](#packagespackageid) | ID of the package. | | <a id="packagebasemetadata"></a>`metadata` | [`PackageMetadata`](#packagemetadata) | Package metadata. | @@ -22057,6 +22058,7 @@ Represents a package in the Package Registry. | <a id="packagebasestatusmessage"></a>`statusMessage` | [`String`](#string) | Status message. | | <a id="packagebasetags"></a>`tags` | [`PackageTagConnection`](#packagetagconnection) | Package tags. (see [Connections](#connections)) | | <a id="packagebaseupdatedat"></a>`updatedAt` | [`Time!`](#time) | Date of most recent update. | +| <a id="packagebaseuserpermissions"></a>`userPermissions` | [`PackagePermissions!`](#packagepermissions) | Permissions for the current user on the resource. | | <a id="packagebaseversion"></a>`version` | [`String`](#string) | Version string. | ### `PackageComposerJsonType` @@ -22106,7 +22108,7 @@ Represents a package details in the Package Registry. | Name | Type | Description | | ---- | ---- | ----------- | | <a id="packagedetailstype_links"></a>`_links` | [`PackageLinks!`](#packagelinks) | Map of links to perform actions on the package. | -| <a id="packagedetailstypecandestroy"></a>`canDestroy` | [`Boolean!`](#boolean) | Whether the user can destroy the package. | +| <a id="packagedetailstypecandestroy"></a>`canDestroy` **{warning-solid}** | [`Boolean!`](#boolean) | **Deprecated** in 16.6. Superseded by `user_permissions` field. See `Types::PermissionTypes::Package` type. | | <a id="packagedetailstypecomposerconfigrepositoryurl"></a>`composerConfigRepositoryUrl` | [`String`](#string) | Url of the Composer setup endpoint. | | <a id="packagedetailstypecomposerurl"></a>`composerUrl` | [`String`](#string) | Url of the Composer endpoint. | | <a id="packagedetailstypeconanurl"></a>`conanUrl` | [`String`](#string) | Url of the Conan project endpoint. | @@ -22130,6 +22132,7 @@ Represents a package details in the Package Registry. | <a id="packagedetailstypestatusmessage"></a>`statusMessage` | [`String`](#string) | Status message. | | <a id="packagedetailstypetags"></a>`tags` | [`PackageTagConnection`](#packagetagconnection) | Package tags. (see [Connections](#connections)) | | <a id="packagedetailstypeupdatedat"></a>`updatedAt` | [`Time!`](#time) | Date of most recent update. | +| <a id="packagedetailstypeuserpermissions"></a>`userPermissions` | [`PackagePermissions!`](#packagepermissions) | Permissions for the current user on the resource. | | <a id="packagedetailstypeversion"></a>`version` | [`String`](#string) | Version string. | | <a id="packagedetailstypeversions"></a>`versions` | [`PackageBaseConnection`](#packagebaseconnection) | Other versions of the package. (see [Connections](#connections)) | @@ -22241,6 +22244,14 @@ Represents links to perform actions on the package. | ---- | ---- | ----------- | | <a id="packagelinkswebpath"></a>`webPath` | [`String`](#string) | Path to the package details page. | +### `PackagePermissions` + +#### Fields + +| Name | Type | Description | +| ---- | ---- | ----------- | +| <a id="packagepermissionsdestroypackage"></a>`destroyPackage` | [`Boolean!`](#boolean) | If `true`, the user can perform `destroy_package` on this resource. | + ### `PackageSettings` Namespace-level Package Registry settings. diff --git a/doc/ci/runners/new_creation_workflow.md b/doc/ci/runners/new_creation_workflow.md index 3465aaf94fc..bf05c1b8286 100644 --- a/doc/ci/runners/new_creation_workflow.md +++ b/doc/ci/runners/new_creation_workflow.md @@ -99,7 +99,7 @@ If you specify a runner authentication token with: Authentication tokens have the prefix, `glrt-`. To ensure minimal disruption to your automation workflow, -[legacy-compatible registration processing](https://docs.gitlab.com/runner/register/#legacy-compatible-registration-processing) +[legacy-compatible registration processing](https://docs.gitlab.com/runner/register/#legacy-compatible-registration-process) triggers if a runner authentication token is specified in the legacy parameter `--registration-token`. Example command for GitLab 15.9: diff --git a/doc/user/project/merge_requests/drafts.md b/doc/user/project/merge_requests/drafts.md index 85ebc75e61f..a3b1920e375 100644 --- a/doc/user/project/merge_requests/drafts.md +++ b/doc/user/project/merge_requests/drafts.md @@ -7,22 +7,19 @@ type: reference, concepts # Draft merge requests **(FREE ALL)** -If a merge request isn't ready to merge, potentially because of continued development -or open threads, you can prevent it from being accepted before you -[mark it as ready](#mark-merge-requests-as-ready). Flag it as a draft to disable -the **Merge** button until you remove the **Draft** flag: +If a merge request isn't ready to merge, you can block it from merging until you +[mark it as ready](#mark-merge-requests-as-ready). Merge requests marked as **Draft** +cannot merge until the **Draft** flag is removed, even if all other merge criteria are met: -![Blocked Merge Button](img/merge_request_draft_blocked_v16_0.png) +![merge is blocked](img/merge_request_draft_blocked_v16_0.png) ## Mark merge requests as drafts -> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/32692) in GitLab 13.2, Work-In-Progress (WIP) merge requests were renamed to **Draft**. -> - [Removed](https://gitlab.com/gitlab-org/gitlab/-/issues/228685) all support for using **WIP** in GitLab 14.8. -> - **Mark as draft** and **Mark as ready** buttons [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/227421) in GitLab 13.5. +> - [Removed](https://gitlab.com/gitlab-org/gitlab/-/issues/228685) all support for the term **WIP** in GitLab 14.8. > `/draft` quick action as a toggle [deprecated](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/92654) in GitLab 15.4. > - [Changed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/108073) the draft status to use a checkbox in GitLab 15.8. -There are several ways to flag a merge request as a draft: +You can flag a merge request as a draft in several ways: - **Viewing a merge request**: In the upper-right corner of the merge request, select **Mark as draft**. - **Creating or editing a merge request**: Add `[Draft]`, `Draft:` or `(Draft)` to @@ -33,12 +30,12 @@ There are several ways to flag a merge request as a draft: in a comment. To mark a merge request as ready, use `/ready`. - **Creating a commit**: Add `draft:`, `Draft:`, `fixup!`, or `Fixup!` to the beginning of a commit message targeting the merge request's source branch. This - is not a toggle, and adding this text again in a later commit doesn't mark the + method is not a toggle. Adding this text again in a later commit doesn't mark the merge request as ready. ## Mark merge requests as ready -When a merge request is ready to be merged, you can remove the `Draft` flag in several ways: +When a merge request is ready to merge, you can remove the `Draft` flag in several ways: - **Viewing a merge request**: In the upper-right corner of the merge request, select **Mark as ready**. Users with at least the Developer role @@ -50,18 +47,18 @@ When a merge request is ready to be merged, you can remove the `Draft` flag in s [quick action](../quick_actions.md#issues-merge-requests-and-epics) in a comment in the merge request. -In [GitLab 13.10 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/15332), -when you mark a merge request as ready, notifications are triggered to -[merge request participants and watchers](../../profile/notifications.md#notifications-on-issues-merge-requests-and-epics). +When you mark a merge request as ready, +[merge request participants and watchers](../../profile/notifications.md#notifications-on-issues-merge-requests-and-epics) +are notified. ## Include or exclude drafts when searching -When viewing or searching in your project's merge requests list, you can include or exclude +When you view or search in your project's merge requests list, to include or exclude draft merge requests: 1. Go to your project and select **Code > Merge requests**. -1. In the navigation bar, select **Open**, **Merged**, **Closed**, or **All** to - filter by merge request status. +1. To filter by merge request status, select **Open**, **Merged**, **Closed**, + or **All** in the navigation bar. 1. Select the search box to display a list of filters and select **Draft**, or enter the word `draft`. 1. Select `=`. @@ -72,9 +69,9 @@ draft merge requests: ## Pipelines for drafts -Draft merge requests run the same pipelines as merge request that are marked as ready. +Draft merge requests run the same pipelines as merge requests marked as ready. -In GitLab 15.0 and older, you must [mark the merge request as ready](#mark-merge-requests-as-ready) +In GitLab 15.0 and earlier, you must [mark the merge request as ready](#mark-merge-requests-as-ready) if you want to run [merged results pipelines](../../../ci/pipelines/merged_results_pipelines.md). <!-- ## Troubleshooting diff --git a/lib/gitlab/composer/version_index.rb b/lib/gitlab/composer/version_index.rb index bfa3112b795..0834fda9cf9 100644 --- a/lib/gitlab/composer/version_index.rb +++ b/lib/gitlab/composer/version_index.rb @@ -48,8 +48,7 @@ module Gitlab end def package_source(package) - use_http_url = package.project.public? || Feature.disabled?(:composer_use_ssh_source_urls, package.project) - git_url = use_http_url ? package.project.http_url_to_repo : package.project.ssh_url_to_repo + git_url = package.project.public? ? package.project.http_url_to_repo : package.project.ssh_url_to_repo { 'type' => 'git', diff --git a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_large_project_spec.rb b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_large_project_spec.rb index 2b1a81f0afb..be9c1aab3ea 100644 --- a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_large_project_spec.rb +++ b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_large_project_spec.rb @@ -343,7 +343,7 @@ module QA imported_mrs = project.merge_requests(auto_paginate: true, attempts: 2) Parallel.map(imported_mrs, in_threads: api_parallel_threads) do |mr| - resource = build(:merge_request, project: project, idd: mr[:iid], api_client: client) + resource = build(:merge_request, project: project, iid: mr[:iid], api_client: client) [mr[:iid], { url: mr[:web_url], diff --git a/spec/features/issues/filtered_search/visual_tokens_spec.rb b/spec/features/issues/filtered_search/visual_tokens_spec.rb index e51c82081ff..ca1a822fd88 100644 --- a/spec/features/issues/filtered_search/visual_tokens_spec.rb +++ b/spec/features/issues/filtered_search/visual_tokens_spec.rb @@ -6,8 +6,8 @@ RSpec.describe 'Visual tokens', :js, feature_category: :team_planning do include FilteredSearchHelpers let_it_be(:project) { create(:project) } - let_it_be(:user) { create(:user, :no_super_sidebar, name: 'administrator', username: 'root') } - let_it_be(:user_rock) { create(:user, :no_super_sidebar, name: 'The Rock', username: 'rock') } + let_it_be(:user) { create(:user, name: 'administrator', username: 'root') } + let_it_be(:user_rock) { create(:user, name: 'The Rock', username: 'rock') } let_it_be(:milestone_nine) { create(:milestone, title: '9.0', project: project) } let_it_be(:milestone_ten) { create(:milestone, title: '10.0', project: project) } let_it_be(:label) { create(:label, project: project, title: 'abc') } @@ -41,7 +41,7 @@ RSpec.describe 'Visual tokens', :js, feature_category: :team_planning do end it 'ends editing mode when document is clicked' do - find('.js-navbar').click + find('body').click(x: 0, y: 0) expect_empty_search_term expect_hidden_suggestions_list diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb index 73c53e855b2..2fb30469691 100644 --- a/spec/features/issues/form_spec.rb +++ b/spec/features/issues/form_spec.rb @@ -7,9 +7,9 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do include ListboxHelpers let_it_be(:project) { create(:project, :repository) } - let_it_be(:user) { create(:user, :no_super_sidebar) } - let_it_be(:user2) { create(:user, :no_super_sidebar) } - let_it_be(:guest) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } + let_it_be(:user2) { create(:user) } + let_it_be(:guest) { create(:user) } let_it_be(:milestone) { create(:milestone, project: project) } let_it_be(:label) { create(:label, project: project) } let_it_be(:label2) { create(:label, project: project) } @@ -526,7 +526,7 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do find('body').send_keys('e') - click_link 'Boards' + click_link 'Homepage' expect(page).not_to have_content(expected_content) end @@ -539,7 +539,7 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do find('body').send_keys('e') fill_in 'issue-description', with: content - click_link 'Boards' do + click_link 'Homepage' do page.driver.browser.switch_to.alert.dismiss end @@ -554,8 +554,8 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do find('body').send_keys('e') fill_in 'issue-description', with: content - click_link 'Boards' do - page.driver.browser.switch_to.alert.accept + click_link 'Homepage' do + page.driver.browser.switch_to.alert.dismiss end expect(page).not_to have_content(content) @@ -601,14 +601,4 @@ RSpec.describe 'New/edit issue', :js, feature_category: :team_planning do end end end - - def before_for_selector(selector) - js = <<-JS.strip_heredoc - (function(selector) { - var el = document.querySelector(selector); - return window.getComputedStyle(el, '::before').getPropertyValue('content'); - })("#{escape_javascript(selector)}") - JS - page.evaluate_script(js) - end end diff --git a/spec/features/merge_request/user_opens_checkout_branch_modal_spec.rb b/spec/features/merge_request/user_opens_checkout_branch_modal_spec.rb index 230111fe439..111e8574bac 100644 --- a/spec/features/merge_request/user_opens_checkout_branch_modal_spec.rb +++ b/spec/features/merge_request/user_opens_checkout_branch_modal_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'Merge request > User opens checkout branch modal', :js, feature_category: :code_review_workflow do include ProjectForksHelper - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :public, :repository, namespace: user.namespace) } before do @@ -13,7 +13,7 @@ RSpec.describe 'Merge request > User opens checkout branch modal', :js, feature_ end describe 'for fork' do - let(:author) { create(:user, :no_super_sidebar) } + let(:author) { create(:user) } let(:source_project) { fork_project(project, author, repository: true) } let(:merge_request) do @@ -31,8 +31,10 @@ RSpec.describe 'Merge request > User opens checkout branch modal', :js, feature_ it 'shows instructions' do visit project_merge_request_path(project, merge_request) - click_button 'Code' - click_button 'Check out branch' + page.within 'main' do + click_button 'Code' + click_button 'Check out branch' + end expect(page).to have_content(source_project.http_url_to_repo) end diff --git a/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb b/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb index 921c12134a9..da290f59736 100644 --- a/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb +++ b/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Merge request > User sees check out branch modal', :js, feature_category: :code_review_workflow do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :public, :repository, creator: user) } let_it_be(:merge_request) { create(:merge_request, source_project: project) } let(:modal_window_title) { 'Check out, review, and resolve locally' } @@ -13,8 +13,10 @@ RSpec.describe 'Merge request > User sees check out branch modal', :js, feature_ visit project_merge_request_path(project, merge_request) wait_for_requests - click_button 'Code' - click_button('Check out branch') + page.within 'main' do + click_button 'Code' + click_button('Check out branch') + end end it 'shows the check out branch modal' do diff --git a/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb b/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb index 654c71c87e0..daa84227adc 100644 --- a/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb +++ b/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'Merge request > User selects branches for new MR', :js, feature_category: :code_review_workflow do include ListboxHelpers - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :public, :repository, namespace: user.namespace) } def select_source_branch(branch_name) @@ -64,8 +64,10 @@ RSpec.describe 'Merge request > User selects branches for new MR', :js, feature_ fill_in "merge_request_title", with: "Orphaned MR test" click_button "Create merge request" - click_button 'Code' - click_button "Check out branch" + page.within 'main' do + click_button 'Code' + click_button "Check out branch" + end expect(page).to have_content 'git checkout -b \'orphaned-branch\' \'origin/orphaned-branch\'' end diff --git a/spec/features/merge_request/user_uses_quick_actions_spec.rb b/spec/features/merge_request/user_uses_quick_actions_spec.rb index b2cc25f1c34..a89f533c9dd 100644 --- a/spec/features/merge_request/user_uses_quick_actions_spec.rb +++ b/spec/features/merge_request/user_uses_quick_actions_spec.rb @@ -13,7 +13,7 @@ RSpec.describe 'Merge request > User uses quick actions', :js, :use_clean_rails_ context "issuable common quick actions" do let!(:new_url_opts) { { merge_request: { source_branch: 'feature', target_branch: 'master' } } } - let(:maintainer) { create(:user, :no_super_sidebar) } + let(:maintainer) { create(:user) } let(:project) { create(:project, :public, :repository) } let!(:label_bug) { create(:label, project: project, title: 'bug') } let!(:label_feature) { create(:label, project: project, title: 'feature') } @@ -26,8 +26,8 @@ RSpec.describe 'Merge request > User uses quick actions', :js, :use_clean_rails_ end describe 'merge-request-only commands' do - let(:user) { create(:user, :no_super_sidebar) } - let(:guest) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } + let(:guest) { create(:user) } let(:project) { create(:project, :public, :repository) } let(:merge_request) { create(:merge_request, source_project: project) } let!(:milestone) { create(:milestone, project: project, title: 'ASAP') } diff --git a/spec/features/projects/confluence/user_views_confluence_page_spec.rb b/spec/features/projects/confluence/user_views_confluence_page_spec.rb index 216bea74c09..9c036f35887 100644 --- a/spec/features/projects/confluence/user_views_confluence_page_spec.rb +++ b/spec/features/projects/confluence/user_views_confluence_page_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'User views the Confluence page', feature_category: :integrations do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let(:project) { create(:project, :public) } @@ -11,12 +11,14 @@ RSpec.describe 'User views the Confluence page', feature_category: :integrations sign_in(user) end - it 'shows the page when the Confluence integration is enabled' do + it 'shows the page when the Confluence integration is enabled', :js do service = create(:confluence_integration, project: project) visit project_wikis_confluence_path(project) - expect(page).to have_css('.nav-sidebar li.active', text: 'Confluence', match: :first) + within_testid('super-sidebar') do + expect(page).to have_css('a[aria-current="page"]', text: 'Confluence') + end element = page.find('.row.empty-state') diff --git a/spec/features/projects/features_visibility_spec.rb b/spec/features/projects/features_visibility_spec.rb index 8f66b722ead..c6a770cee9e 100644 --- a/spec/features/projects/features_visibility_spec.rb +++ b/spec/features/projects/features_visibility_spec.rb @@ -3,10 +3,15 @@ require 'spec_helper' RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects do - let(:member) { create(:user, :no_super_sidebar) } + let(:member) { create(:user) } let!(:project) { create(:project, :public, :repository) } let!(:issue) { create(:issue, project: project) } - let(:non_member) { create(:user, :no_super_sidebar) } + let(:non_member) { create(:user) } + + # Sidebar nav links are only visible after hovering over or expanding the + # section that contains them (if it exists). Finding visible and hidden + # nav links allows us to avoid doing that. + let(:visibility_all) { { visible: :all } } describe 'project features visibility selectors', :js do before do @@ -14,7 +19,7 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d sign_in(member) end - tools = { builds: "pipelines", issues: "issues", wiki: "wiki", snippets: "snippets", merge_requests: "merge_requests", analytics: "analytics" } + tools = { builds: "pipelines", issues: "issues", wiki: "wiki", snippets: "snippets", merge_requests: "merge_requests", analytics: "project-cycle-analytics" } tools.each do |tool_name, shortcut_name| describe "feature #{tool_name}" do @@ -22,20 +27,16 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d visit edit_project_path(project) # disable by clicking toggle - toggle_feature_off("project[project_feature_attributes][#{tool_name}_access_level]") - page.within('.sharing-permissions') do - find('[data-testid="project-features-save-button"]').click - end + toggle_feature_off(tool_name) + click_save_changes wait_for_requests - expect(page).not_to have_selector(".shortcuts-#{shortcut_name}") + expect(page).not_to have_selector(".shortcuts-#{shortcut_name}", **visibility_all) # re-enable by clicking toggle again - toggle_feature_on("project[project_feature_attributes][#{tool_name}_access_level]") - page.within('.sharing-permissions') do - find('[data-testid="project-features-save-button"]').click - end + toggle_feature_on(tool_name) + click_save_changes wait_for_requests - expect(page).to have_selector(".shortcuts-#{shortcut_name}") + expect(page).to have_selector(".shortcuts-#{shortcut_name}", **visibility_all) end end end @@ -48,8 +49,8 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d visit project_path(project) - expect(page).to have_selector('.shortcuts-issues') - expect(page).not_to have_selector('.shortcuts-labels') + expect(page).to have_selector('.shortcuts-issues', **visibility_all) + expect(page).not_to have_selector('.shortcuts-labels', **visibility_all) end end @@ -65,8 +66,8 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d it 'hides issues tab' do visit project_path(project) - expect(page).not_to have_selector('.shortcuts-issues') - expect(page).not_to have_selector('.shortcuts-labels') + expect(page).not_to have_selector('.shortcuts-issues', **visibility_all) + expect(page).not_to have_selector('.shortcuts-labels', **visibility_all) end end @@ -74,7 +75,7 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d it "shows builds when enabled" do visit project_pipelines_path(project) - expect(page).to have_selector(".shortcuts-builds") + expect(page).to have_selector(".shortcuts-builds", **visibility_all) end it "hides builds when disabled" do @@ -83,7 +84,7 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d visit project_pipelines_path(project) - expect(page).not_to have_selector(".shortcuts-builds") + expect(page).not_to have_selector(".shortcuts-builds", **visibility_all) end end end @@ -183,23 +184,19 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d end it "disables repository related features" do - toggle_feature_off('project[project_feature_attributes][repository_access_level]') + toggle_feature_off('repository') - page.within('.sharing-permissions') do - click_button "Save changes" - end + click_save_changes expect(find(".sharing-permissions")).to have_selector(".gl-toggle.is-disabled", minimum: 3) end it "shows empty features project homepage" do - toggle_feature_off('project[project_feature_attributes][repository_access_level]') - toggle_feature_off('project[project_feature_attributes][issues_access_level]') - toggle_feature_off('project[project_feature_attributes][wiki_access_level]') + toggle_feature_off('repository') + toggle_feature_off('issues') + toggle_feature_off('wiki') - page.within('.sharing-permissions') do - click_button "Save changes" - end + click_save_changes wait_for_requests visit project_path(project) @@ -208,13 +205,11 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d end it "hides project activity tabs" do - toggle_feature_off('project[project_feature_attributes][repository_access_level]') - toggle_feature_off('project[project_feature_attributes][issues_access_level]') - toggle_feature_off('project[project_feature_attributes][wiki_access_level]') + toggle_feature_off('repository') + toggle_feature_off('issues') + toggle_feature_off('wiki') - page.within('.sharing-permissions') do - click_button "Save changes" - end + click_save_changes wait_for_requests visit activity_project_path(project) @@ -229,7 +224,7 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d # Regression spec for https://gitlab.com/gitlab-org/gitlab-foss/issues/25272 it "hides comments activity tab only on disabled issues, merge requests and repository" do - toggle_feature_off('project[project_feature_attributes][issues_access_level]') + toggle_feature_off('issues') save_changes_and_check_activity_tab do expect(page).to have_content("Comments") @@ -237,7 +232,7 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d visit edit_project_path(project) - toggle_feature_off('project[project_feature_attributes][merge_requests_access_level]') + toggle_feature_off('merge_requests') save_changes_and_check_activity_tab do expect(page).to have_content("Comments") @@ -245,7 +240,7 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d visit edit_project_path(project) - toggle_feature_off('project[project_feature_attributes][repository_access_level]') + toggle_feature_off('repository') save_changes_and_check_activity_tab do expect(page).not_to have_content("Comments") @@ -255,9 +250,7 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d end def save_changes_and_check_activity_tab - page.within('.sharing-permissions') do - click_button "Save changes" - end + click_save_changes wait_for_requests visit activity_project_path(project) @@ -284,10 +277,16 @@ RSpec.describe 'Edit Project Settings', feature_category: :groups_and_projects d end def toggle_feature_off(feature_name) - find(".project-feature-controls[data-for=\"#{feature_name}\"] .gl-toggle.is-checked").click + find(".project-feature-controls[data-for=\"project[project_feature_attributes][#{feature_name}_access_level]\"] .gl-toggle.is-checked").click end def toggle_feature_on(feature_name) - find(".project-feature-controls[data-for=\"#{feature_name}\"] .gl-toggle:not(.is-checked)").click + find(".project-feature-controls[data-for=\"project[project_feature_attributes][#{feature_name}_access_level]\"] .gl-toggle:not(.is-checked)").click + end + + def click_save_changes + page.within('.sharing-permissions') do + click_button 'Save changes' + end end end diff --git a/spec/features/projects/files/user_searches_for_files_spec.rb b/spec/features/projects/files/user_searches_for_files_spec.rb index 627912df408..030d5a8ec40 100644 --- a/spec/features/projects/files/user_searches_for_files_spec.rb +++ b/spec/features/projects/files/user_searches_for_files_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Projects > Files > User searches for files', feature_category: :groups_and_projects do - let_it_be(:user) { create(:user, :no_super_sidebar) } + let_it_be(:user) { create(:user) } let_it_be(:project) { create(:project, :repository, namespace: user.namespace) } before do @@ -18,7 +18,7 @@ RSpec.describe 'Projects > Files > User searches for files', feature_category: : visit project_path(project) end - it 'does not show any result' do + it 'does not show any result', :js do submit_search('coffee') expect(page).to have_content("We couldn't find any") @@ -41,7 +41,7 @@ RSpec.describe 'Projects > Files > User searches for files', feature_category: : visit project_tree_path(project, project.default_branch) end - it 'shows found files' do + it 'shows found files', :js do expect(page).to have_selector('.tree-controls .shortcuts-find-file') submit_search('coffee') diff --git a/spec/features/projects/graph_spec.rb b/spec/features/projects/graph_spec.rb index 9b0803e4b0c..e9c05fd7f7f 100644 --- a/spec/features/projects/graph_spec.rb +++ b/spec/features/projects/graph_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' RSpec.describe 'Project Graph', :js, feature_category: :groups_and_projects do - let(:user) { create(:user, :no_super_sidebar) } + let(:user) { create(:user) } let(:project) { create(:project, :repository, namespace: user.namespace) } let(:branch_name) { 'master' } @@ -59,7 +59,7 @@ RSpec.describe 'Project Graph', :js, feature_category: :groups_and_projects do it 'HTML escapes branch name' do expect(page.body).to include("Commit statistics for <strong>#{ERB::Util.html_escape(branch_name)}</strong>") - expect(page.find('.gl-new-dropdown-button-text')['innerHTML']).to include(ERB::Util.html_escape(branch_name)) + expect(page).to have_button(branch_name) end end diff --git a/spec/fixtures/api/schemas/graphql/packages/package_details.json b/spec/fixtures/api/schemas/graphql/packages/package_details.json index 2e7a950d330..1acc3f6ad7d 100644 --- a/spec/fixtures/api/schemas/graphql/packages/package_details.json +++ b/spec/fixtures/api/schemas/graphql/packages/package_details.json @@ -17,7 +17,8 @@ "statusMessage", "canDestroy", "lastDownloadedAt", - "_links" + "_links", + "userPermissions" ], "properties": { "id": { @@ -272,6 +273,15 @@ ] } } + }, + "userPermissions": { + "type": "object", + "additionalProperties": false, + "properties": { + "destroyPackage": { + "type": "boolean" + } + } } } } diff --git a/spec/graphql/types/packages/package_base_type_spec.rb b/spec/graphql/types/packages/package_base_type_spec.rb index ebe29da0539..6b568f4ae7f 100644 --- a/spec/graphql/types/packages/package_base_type_spec.rb +++ b/spec/graphql/types/packages/package_base_type_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' RSpec.describe GitlabSchema.types['PackageBase'], feature_category: :package_registry do specify { expect(described_class.description).to eq('Represents a package in the Package Registry') } - specify { expect(described_class).to require_graphql_authorizations(:read_package) } + specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Package) } it 'includes all expected fields' do expected_fields = %w[ @@ -14,6 +14,7 @@ RSpec.describe GitlabSchema.types['PackageBase'], feature_category: :package_reg project tags metadata status status_message can_destroy + user_permissions ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/packages/package_details_type_spec.rb b/spec/graphql/types/packages/package_details_type_spec.rb index e4fe53f7660..464e81c0a8c 100644 --- a/spec/graphql/types/packages/package_details_type_spec.rb +++ b/spec/graphql/types/packages/package_details_type_spec.rb @@ -2,17 +2,17 @@ require 'spec_helper' -RSpec.describe GitlabSchema.types['PackageDetailsType'] do +RSpec.describe GitlabSchema.types['PackageDetailsType'], feature_category: :package_registry do specify { expect(described_class.description).to eq('Represents a package details in the Package Registry') } - specify { expect(described_class).to require_graphql_authorizations(:read_package) } + specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Package) } it 'includes all the package fields' do expected_fields = %w[ id name version created_at updated_at package_type tags project pipelines versions package_files dependency_links public_package npm_url maven_url conan_url nuget_url pypi_url pypi_setup_url - composer_url composer_config_repository_url + composer_url composer_config_repository_url user_permissions ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/packages/package_type_spec.rb b/spec/graphql/types/packages/package_type_spec.rb index df8135ed87e..dc1cc6a8bad 100644 --- a/spec/graphql/types/packages/package_type_spec.rb +++ b/spec/graphql/types/packages/package_type_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper' -RSpec.describe GitlabSchema.types['Package'] do +RSpec.describe GitlabSchema.types['Package'], feature_category: :package_registry do specify { expect(described_class.description).to eq('Represents a package with pipelines in the Package Registry') } - specify { expect(described_class).to require_graphql_authorizations(:read_package) } + specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Package) } it 'includes all the package fields and pipelines' do expected_fields = %w[ @@ -14,6 +14,7 @@ RSpec.describe GitlabSchema.types['Package'] do project tags pipelines metadata status can_destroy + user_permissions ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/graphql/types/permission_types/package_spec.rb b/spec/graphql/types/permission_types/package_spec.rb new file mode 100644 index 00000000000..3de37438234 --- /dev/null +++ b/spec/graphql/types/permission_types/package_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe GitlabSchema.types['PackagePermissions'], feature_category: :package_registry do + it 'has the expected fields' do + expected_permissions = [:destroy_package] + + expect(described_class).to have_graphql_fields(expected_permissions).only + end +end diff --git a/spec/lib/gitlab/composer/version_index_spec.rb b/spec/lib/gitlab/composer/version_index_spec.rb index 63efa8cae95..c5bc6dc0195 100644 --- a/spec/lib/gitlab/composer/version_index_spec.rb +++ b/spec/lib/gitlab/composer/version_index_spec.rb @@ -83,32 +83,6 @@ RSpec.describe Gitlab::Composer::VersionIndex, feature_category: :package_regist it_behaves_like 'returns the packages json' end - - context 'with composer_use_ssh_source_urls disabled' do - before do - stub_feature_flags(composer_use_ssh_source_urls: false) - end - - context 'with a public project' do - it_behaves_like 'returns the packages json' - end - - context 'with an internal project' do - before do - project.update!(visibility: Gitlab::VisibilityLevel::INTERNAL) - end - - it_behaves_like 'returns the packages json' - end - - context 'with a private project' do - before do - project.update!(visibility: Gitlab::VisibilityLevel::PRIVATE) - end - - it_behaves_like 'returns the packages json' - end - end end describe '#sha' do diff --git a/spec/tooling/danger/datateam_spec.rb b/spec/tooling/danger/datateam_spec.rb index dff355eedc6..85fcc20fd7c 100644 --- a/spec/tooling/danger/datateam_spec.rb +++ b/spec/tooling/danger/datateam_spec.rb @@ -16,20 +16,27 @@ RSpec.describe Tooling::Danger::Datateam do where do { - 'with structure.sql changes and no Data Warehouse::Impact Check label' => { + 'with structure.sql subtraction changes and no Data Warehouse::Impact Check label' => { modified_files: %w(db/structure.sql app/models/user.rb), - changed_lines: ['+group_id bigint NOT NULL'], + changed_lines: ['-group_id bigint NOT NULL'], mr_labels: [], impacted: true, impacted_files: %w(db/structure.sql) }, - 'with structure.sql changes and Data Warehouse::Impact Check label' => { + 'with structure.sql subtraction changes and Data Warehouse::Impact Check label' => { modified_files: %w(db/structure.sql), - changed_lines: ['+group_id bigint NOT NULL)'], + changed_lines: ['-group_id bigint NOT NULL)'], mr_labels: ['Data Warehouse::Impact Check'], impacted: false, impacted_files: %w(db/structure.sql) }, + 'with structure.sql addition changes and no Data Warehouse::Impact Check label' => { + modified_files: %w(db/structure.sql app/models/user.rb), + changed_lines: ['+group_id bigint NOT NULL'], + mr_labels: [], + impacted: false, + impacted_files: %w(db/structure.sql) + }, 'with user model changes' => { modified_files: %w(app/models/users.rb), changed_lines: ['+has_one :namespace'], diff --git a/tooling/danger/datateam.rb b/tooling/danger/datateam.rb index 1354e684d50..7100ac16f69 100644 --- a/tooling/danger/datateam.rb +++ b/tooling/danger/datateam.rb @@ -17,7 +17,7 @@ module Tooling PERFORMANCE_INDICATOR_REGEX = %r{gmau|smau|paid_gmau|umau} METRIC_REMOVED = %r{\+status: removed} DATABASE_REGEX = %r{\Adb/structure\.sql} - STRUCTURE_SQL_FILE = %w[db/structure.sql].freeze + DATABASE_LINE_REMOVAL_REGEX = %r{\A-} def build_message return unless impacted? @@ -47,12 +47,15 @@ module Tooling end.compact end - def database_changes? - !helper.modified_files.grep(DATABASE_REGEX).empty? + def database_changed_files + database_changed_files = helper.modified_files.grep(DATABASE_REGEX) + database_changed_files.select do |file| + helper.changed_lines(file).any? { |change| database_line_removal?(change) } + end.compact end - def database_changed_files - helper.modified_files & STRUCTURE_SQL_FILE + def database_line_removal?(change) + change =~ DATABASE_LINE_REMOVAL_REGEX end def performance_indicator_changed?(change) |