From 94ca43181461c52ca0381d414387b02e579dbc61 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 24 Feb 2022 18:19:04 +0000 Subject: [PATCH] Add latest changes from gitlab-org/gitlab@master --- Dangerfile | 2 +- GITALY_SERVER_VERSION | 2 +- .../pipelines_list/pipeline_url.vue | 14 ++-- app/controllers/projects/builds_controller.rb | 3 + app/controllers/projects/jobs_controller.rb | 2 + .../projects/merge_requests_controller.rb | 3 +- .../projects/pipelines/stages_controller.rb | 4 + .../projects/pipelines_controller.rb | 3 + app/graphql/resolvers/blobs_resolver.rb | 9 +++ app/helpers/todos_helper.rb | 2 +- app/models/work_item.rb | 8 ++ app/views/projects/empty.html.haml | 80 +++++++++---------- app/views/projects/pipelines/_info.html.haml | 4 +- ...0352_users_creating_work_items_monthly.yml | 25 ++++++ ...10026_users_creating_work_items_weekly.yml | 25 ++++++ ...00000_async_build_trace_expire_at_index.rb | 14 ++++ db/schema_migrations/20220224000000 | 1 + doc/.vale/gitlab/Substitutions.yml | 1 + doc/administration/feature_flags.md | 2 +- doc/api/group_wikis.md | 21 +++-- doc/api/merge_request_approvals.md | 6 +- doc/api/merge_requests.md | 4 +- doc/api/wikis.md | 20 +++-- .../documentation/styleguide/word_list.md | 5 ++ .../insert_into_tables_in_batches.md | 2 +- doc/development/kubernetes.md | 2 +- doc/development/snowplow/implementation.md | 2 +- doc/integration/elasticsearch.md | 2 +- doc/security/two_factor_authentication.md | 2 +- .../group/saml_sso/group_managed_accounts.md | 2 +- lib/api/ci/jobs.rb | 18 ++--- lib/api/ci/pipelines.rb | 2 +- lib/api/ci/runner.rb | 6 +- lib/api/entities/wiki_page.rb | 4 + lib/gitlab/ci/config/external/file/local.rb | 4 + .../known_events/work_items.yml | 5 ++ .../work_item_activity_unique_counter.rb | 5 ++ locale/gitlab.pot | 40 ++++++---- .../dashboard/todos/todos_filtering_spec.rb | 2 +- spec/features/dashboard/todos/todos_spec.rb | 2 +- .../user_sees_merge_request_pipelines_spec.rb | 18 +++-- .../merge_request/user_sees_pipelines_spec.rb | 2 +- .../projects/pipelines/pipeline_spec.rb | 2 +- .../projects/pipelines/pipelines_spec.rb | 9 ++- spec/frontend/pipelines/pipeline_url_spec.js | 4 +- spec/graphql/resolvers/blobs_resolver_spec.rb | 22 +++++ spec/lib/api/entities/wiki_page_spec.rb | 17 ++++ .../ci/config/external/file/local_spec.rb | 10 +++ .../work_item_activity_unique_counter_spec.rb | 24 ++++-- spec/models/work_item_spec.rb | 12 +++ spec/requests/api/wikis_spec.rb | 2 +- .../shared_examples/lib/wikis_api_examples.rb | 8 +- 52 files changed, 354 insertions(+), 136 deletions(-) create mode 100644 config/metrics/counts_28d/20220221210352_users_creating_work_items_monthly.yml create mode 100644 config/metrics/counts_7d/20220221210026_users_creating_work_items_weekly.yml create mode 100644 db/post_migrate/20220224000000_async_build_trace_expire_at_index.rb create mode 100644 db/schema_migrations/20220224000000 create mode 100644 spec/lib/api/entities/wiki_page_spec.rb diff --git a/Dangerfile b/Dangerfile index ca729f1b941..1fc2005498d 100644 --- a/Dangerfile +++ b/Dangerfile @@ -43,5 +43,5 @@ if project_helper.labels_to_add.any? end if anything_to_post - markdown("**If needed, you can retry the [`danger-review` job](#{ENV['CI_JOB_URL']}) that generated this comment.**") + markdown("**If needed, you can retry the [🔁 `danger-review` job](#{ENV['CI_JOB_URL']}) that generated this comment.**") end diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index 551f0d5cc31..cf82303033e 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -c35fba1c073deed91d1a1f9f11dd668856841d80 +1e442ff0382ed147e7bc4682cd9c278a56163a42 diff --git a/app/assets/javascripts/pipelines/components/pipelines_list/pipeline_url.vue b/app/assets/javascripts/pipelines/components/pipelines_list/pipeline_url.vue index 7c78abae77f..92ed361bcc9 100644 --- a/app/assets/javascripts/pipelines/components/pipelines_list/pipeline_url.vue +++ b/app/assets/javascripts/pipelines/components/pipelines_list/pipeline_url.vue @@ -248,11 +248,15 @@ export default { {{ __('train') }}{{ s__('Pipeline|merge train') }} {{ __('detached') }}{{ s__('Pipeline|merge request') }} < - git push -u origin #{h default_branch_name } + %h5= _('Create a new repository') + %pre.bg-light + :preserve + git clone #{ content_tag(:span, default_url_to_repo, class: 'js-clone')} + cd #{h @project.path} + git switch -c #{h default_branch_name} + touch README.md + git add README.md + git commit -m "add README" + - if @project.can_current_user_push_to_default_branch? + %span>< + git push -u origin #{h default_branch_name } - %fieldset - %h5= _('Push an existing folder') - %pre.bg-light - :preserve - cd existing_folder - git init --initial-branch=#{h default_branch_name} - git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'js-clone')} - git add . - git commit -m "Initial commit" - - if @project.can_current_user_push_to_default_branch? - %span>< - git push -u origin #{h default_branch_name } + %h5= _('Push an existing folder') + %pre.bg-light + :preserve + cd existing_folder + git init --initial-branch=#{h default_branch_name} + git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'js-clone')} + git add . + git commit -m "Initial commit" + - if @project.can_current_user_push_to_default_branch? + %span>< + git push -u origin #{h default_branch_name } - %fieldset - %h5= _('Push an existing Git repository') - %pre.bg-light - :preserve - cd existing_repo - git remote rename origin old-origin - git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'js-clone')} - - if @project.can_current_user_push_to_default_branch? - %span>< - git push -u origin --all - git push -u origin --tags + %h5= _('Push an existing Git repository') + %pre.bg-light + :preserve + cd existing_repo + git remote rename origin old-origin + git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'js-clone')} + - if @project.can_current_user_push_to_default_branch? + %span>< + git push -u origin --all + git push -u origin --tags - if @project.upload_anchor_data.present? = render 'projects/blob/upload', title: _('Upload New File'), placeholder: _('Upload New File'), button_title: _('Upload file'), form_path: project_create_blob_path(@project, default_branch_name), ref: default_branch_name, method: :post diff --git a/app/views/projects/pipelines/_info.html.haml b/app/views/projects/pipelines/_info.html.haml index 4e93d7a04e7..54435f675a7 100644 --- a/app/views/projects/pipelines/_info.html.haml +++ b/app/views/projects/pipelines/_info.html.haml @@ -27,7 +27,7 @@ - if @pipeline.latest? = gl_badge_tag s_('Pipelines|latest'), { variant: :success, size: :sm }, { class: 'js-pipeline-url-latest has-tooltip', title: _("Latest pipeline for the most recent commit on this branch") } - if @pipeline.merge_train_pipeline? - = gl_badge_tag s_('Pipelines|train'), { variant: :info, size: :sm }, { class: 'js-pipeline-url-train has-tooltip', title: _("This is a merge train pipeline") } + = gl_badge_tag s_('Pipelines|merge train'), { variant: :info, size: :sm }, { class: 'js-pipeline-url-train has-tooltip', title: s_("Pipelines|This pipeline ran on the contents of this merge request combined with the contents of all other merge requests queued for merging into the target branch.") } - if @pipeline.has_yaml_errors? = gl_badge_tag s_('Pipelines|yaml invalid'), { variant: :danger, size: :sm }, { class: 'js-pipeline-url-yaml has-tooltip', title: @pipeline.yaml_errors } - if @pipeline.failure_reason? @@ -38,7 +38,7 @@ - popover_content_text = _('Learn more about Auto DevOps') = gl_badge_tag s_('Pipelines|Auto DevOps'), { variant: :info, size: :sm }, { class: 'js-pipeline-url-autodevops', href: "#", tabindex: "0", role: "button", data: { container: 'body', toggle: 'popover', placement: 'top', html: 'true', triggers: 'focus', title: "
#{popover_title_text}
", content: "#{popover_content_text}" } } - if @pipeline.detached_merge_request_pipeline? - = gl_badge_tag s_('Pipelines|detached'), { variant: :info, size: :sm }, { class: 'js-pipeline-url-mergerequest has-tooltip', title: _('Merge request pipelines are configured. A detached pipeline runs in the context of the merge request, and not against the merged result. Learn more in the documentation for merge request pipelines.') } + = gl_badge_tag s_('Pipelines|merge request'), { variant: :info, size: :sm }, { class: 'js-pipeline-url-mergerequest has-tooltip', title: s_("Pipelines|This pipeline ran on the contents of this merge request's source branch, not the target branch.") } - if @pipeline.stuck? = gl_badge_tag s_('Pipelines|stuck'), { variant: :warning, size: :sm }, { class: 'js-pipeline-url-stuck has-tooltip' } diff --git a/config/metrics/counts_28d/20220221210352_users_creating_work_items_monthly.yml b/config/metrics/counts_28d/20220221210352_users_creating_work_items_monthly.yml new file mode 100644 index 00000000000..30cd65425fe --- /dev/null +++ b/config/metrics/counts_28d/20220221210352_users_creating_work_items_monthly.yml @@ -0,0 +1,25 @@ +--- +key_path: redis_hll_counters.work_items.users_creating_work_items_monthly +description: Unique users creating work items +product_category: team planning +product_section: dev +product_stage: plan +product_group: group::project management +value_type: number +status: active +milestone: '14.9' +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81201 +time_frame: 28d +data_source: redis_hll +data_category: optional +instrumentation_class: RedisHLLMetric +options: + events: + - users_creating_work_items +distribution: +- ce +- ee +tier: +- free +- premium +- ultimate diff --git a/config/metrics/counts_7d/20220221210026_users_creating_work_items_weekly.yml b/config/metrics/counts_7d/20220221210026_users_creating_work_items_weekly.yml new file mode 100644 index 00000000000..0c7e18ec458 --- /dev/null +++ b/config/metrics/counts_7d/20220221210026_users_creating_work_items_weekly.yml @@ -0,0 +1,25 @@ +--- +key_path: redis_hll_counters.work_items.users_creating_work_items_weekly +description: Unique users creating work items +product_category: team planning +product_section: dev +product_stage: plan +product_group: group::project management +value_type: number +status: active +milestone: '14.9' +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81201 +time_frame: 7d +data_source: redis_hll +data_category: optional +instrumentation_class: RedisHLLMetric +options: + events: + - users_creating_work_items +distribution: +- ce +- ee +tier: +- free +- premium +- ultimate diff --git a/db/post_migrate/20220224000000_async_build_trace_expire_at_index.rb b/db/post_migrate/20220224000000_async_build_trace_expire_at_index.rb new file mode 100644 index 00000000000..b22f3e7996f --- /dev/null +++ b/db/post_migrate/20220224000000_async_build_trace_expire_at_index.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class AsyncBuildTraceExpireAtIndex < Gitlab::Database::Migration[1.0] + INDEX_NAME = 'tmp_index_ci_job_artifacts_on_id_where_trace_and_expire_at' + TIMESTAMPS = "'2021-04-22 00:00:00', '2021-05-22 00:00:00', '2021-06-22 00:00:00', '2022-01-22 00:00:00', '2022-02-22 00:00:00', '2022-03-22 00:00:00', '2022-04-22 00:00:00'" + + def up + prepare_async_index :ci_job_artifacts, :id, where: "file_type = 3 AND expire_at IN (#{TIMESTAMPS})", name: INDEX_NAME + end + + def down + unprepare_async_index :ci_builds, :id, name: INDEX_NAME + end +end diff --git a/db/schema_migrations/20220224000000 b/db/schema_migrations/20220224000000 new file mode 100644 index 00000000000..e6e9aefbabb --- /dev/null +++ b/db/schema_migrations/20220224000000 @@ -0,0 +1 @@ +74b4d572118b7f5da0a80722601a4757ce47ccbdae1af1e84b2304343477d634 \ No newline at end of file diff --git a/doc/.vale/gitlab/Substitutions.yml b/doc/.vale/gitlab/Substitutions.yml index 1cc5a60ac91..a0670d75f18 100644 --- a/doc/.vale/gitlab/Substitutions.yml +++ b/doc/.vale/gitlab/Substitutions.yml @@ -13,6 +13,7 @@ ignorecase: true swap: codequality: code quality Customer [Pp]ortal: Customers Portal + disallow: prevent frontmatter: front matter GitLabber: GitLab team member GitLabbers: GitLab team members diff --git a/doc/administration/feature_flags.md b/doc/administration/feature_flags.md index 85a7304b5e8..aebd6eb1d4c 100644 --- a/doc/administration/feature_flags.md +++ b/doc/administration/feature_flags.md @@ -26,7 +26,7 @@ Features behind flags can be gradually rolled out, typically: 1. The feature becomes enabled by default. 1. The feature flag is removed. -These features can be enabled and disabled to allow or disallow users to use +These features can be enabled and disabled to allow or prevent users from using them. It can be done by GitLab administrators with access to GitLab Rails console. diff --git a/doc/api/group_wikis.md b/doc/api/group_wikis.md index 4af907bd387..cff30589d0c 100644 --- a/doc/api/group_wikis.md +++ b/doc/api/group_wikis.md @@ -7,7 +7,8 @@ type: reference, api # Group wikis API **(PREMIUM)** -> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/212199) in GitLab 13.5. +> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/212199) in GitLab 13.5. +> - The `encoding` field was [added](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81150) in GitLab 14.9. The [group wikis](../user/project/wiki/group.md) API is available only in APIv4. An API for [project wikis](wikis.md) is also available. @@ -37,18 +38,21 @@ Example response: "content" : "Here is an instruction how to deploy this project.", "format" : "markdown", "slug" : "deploy", - "title" : "deploy" + "title" : "deploy", + "encoding": "UTF-8" }, { "content" : "Our development process is described here.", "format" : "markdown", "slug" : "development", - "title" : "development" + "title" : "development", + "encoding": "UTF-8" },{ "content" : "* [Deploy](deploy)\n* [Development](development)", "format" : "markdown", "slug" : "home", - "title" : "home" + "title" : "home", + "encoding": "UTF-8" } ] ``` @@ -77,7 +81,8 @@ Example response: "content" : "home page", "format" : "markdown", "slug" : "home", - "title" : "home" + "title" : "home", + "encoding": "UTF-8" } ``` @@ -109,7 +114,8 @@ Example response: "content" : "Hello world", "format" : "markdown", "slug" : "Hello", - "title" : "Hello" + "title" : "Hello", + "encoding": "UTF-8" } ``` @@ -142,7 +148,8 @@ Example response: "content" : "documentation", "format" : "markdown", "slug" : "Docs", - "title" : "Docs" + "title" : "Docs", + "encoding": "UTF-8" } ``` diff --git a/doc/api/merge_request_approvals.md b/doc/api/merge_request_approvals.md index 6a0b66ac5dc..e569abd323e 100644 --- a/doc/api/merge_request_approvals.md +++ b/doc/api/merge_request_approvals.md @@ -58,9 +58,9 @@ POST /projects/:id/approvals | `id` | integer or string | yes | The ID or [URL-encoded path of a project](index.md#namespaced-path-encoding) | | `approvals_before_merge` | integer | no | How many approvals are required before an MR can be merged. Deprecated in 12.0 in favor of Approval Rules API. | | `reset_approvals_on_push` | boolean | no | Reset approvals on a new push | -| `disable_overriding_approvers_per_merge_request` | boolean | no | Allow/Disallow overriding approvers per MR | -| `merge_requests_author_approval` | boolean | no | Allow/Disallow authors from self approving merge requests; `true` means authors can self approve | -| `merge_requests_disable_committers_approval` | boolean | no | Allow/Disallow committers from self approving merge requests | +| `disable_overriding_approvers_per_merge_request` | boolean | no | Allow or prevent overriding approvers per MR | +| `merge_requests_author_approval` | boolean | no | Allow or prevent authors from self approving merge requests; `true` means authors can self approve | +| `merge_requests_disable_committers_approval` | boolean | no | Allow or prevent committers from self approving merge requests | | `require_password_to_approve` | boolean | no | Require approver to enter a password to authenticate before adding the approval | ```json diff --git a/doc/api/merge_requests.md b/doc/api/merge_requests.md index 9b9af46955d..0c065c0f2f5 100644 --- a/doc/api/merge_requests.md +++ b/doc/api/merge_requests.md @@ -775,8 +775,8 @@ the `approvals_before_merge` parameter: ### Single merge request response notes - The `merge_status` field may hold one of the following values: - - `unchecked`: We have not checked this yet. - - `checking`: We are currently checking if the merge request can be merged. + - `unchecked`: This merge request has not yet been checked. + - `checking`: This merge request is currently being checked to see if it can be merged. - `can_be_merged`: This merge request can be merged without conflict. - `cannot_be_merged`: There are merge conflicts between the source and target branches. - `cannot_be_merged_recheck`: Currently unchecked. Before the current changes, there were conflicts. diff --git a/doc/api/wikis.md b/doc/api/wikis.md index fb49e9465bc..e2c6c93f3cc 100644 --- a/doc/api/wikis.md +++ b/doc/api/wikis.md @@ -6,6 +6,8 @@ info: To determine the technical writer assigned to the Stage/Group associated w # Project wikis API **(FREE)** +> The `encoding` field was [added](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81150) in GitLab 14.9. + The project [wikis](../user/project/wiki/index.md) API is available only in APIv4. An API for [group wikis](group_wikis.md) is also available. @@ -34,18 +36,21 @@ Example response: "content" : "Here is an instruction how to deploy this project.", "format" : "markdown", "slug" : "deploy", - "title" : "deploy" + "title" : "deploy", + "encoding": "UTF-8" }, { "content" : "Our development process is described here.", "format" : "markdown", "slug" : "development", - "title" : "development" + "title" : "development", + "encoding": "UTF-8" },{ "content" : "* [Deploy](deploy)\n* [Development](development)", "format" : "markdown", "slug" : "home", - "title" : "home" + "title" : "home", + "encoding": "UTF-8" } ] ``` @@ -74,7 +79,8 @@ Example response: "content" : "home page", "format" : "markdown", "slug" : "home", - "title" : "home" + "title" : "home", + "encoding": "UTF-8" } ``` @@ -105,7 +111,8 @@ Example response: "content" : "Hello world", "format" : "markdown", "slug" : "Hello", - "title" : "Hello" + "title" : "Hello", + "encoding": "UTF-8" } ``` @@ -137,7 +144,8 @@ Example response: "content" : "documentation", "format" : "markdown", "slug" : "Docs", - "title" : "Docs" + "title" : "Docs", + "encoding": "UTF-8" } ``` diff --git a/doc/development/documentation/styleguide/word_list.md b/doc/development/documentation/styleguide/word_list.md index 407bf0c09f9..b4a1ce8d4a4 100644 --- a/doc/development/documentation/styleguide/word_list.md +++ b/doc/development/documentation/styleguide/word_list.md @@ -252,6 +252,11 @@ Do not use **Developer permissions**. A user who is assigned the Developer role See [the Microsoft style guide](https://docs.microsoft.com/en-us/style-guide/a-z-word-list-term-collections/d/disable-disabled) for guidance on **disable**. Use **inactive** or **off** instead. ([Vale](../testing.md#vale) rule: [`InclusionAbleism.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/doc/.vale/gitlab/InclusionAbleism.yml)) + +## disallow + +Use **prevent** instead of **disallow**. ([Vale](../testing.md#vale) rule: [`Substitutions.yml`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/doc/.vale/gitlab/Substitutions.yml)) + ## dropdown list Use **dropdown list** to refer to the UI element. Do not use **dropdown** without **list** after it. diff --git a/doc/development/insert_into_tables_in_batches.md b/doc/development/insert_into_tables_in_batches.md index cfa0c862471..cd659a3d19b 100644 --- a/doc/development/insert_into_tables_in_batches.md +++ b/doc/development/insert_into_tables_in_batches.md @@ -122,7 +122,7 @@ Large parts of ActiveRecord's persistence API are built around the notion of cal of these callbacks fire in response to model life cycle events such as `save` or `create`. These callbacks cannot be used with bulk insertions, since they are meant to be called for every instance that is saved or created. Since these events do not fire when -records are inserted in bulk, we currently disallow their use. +records are inserted in bulk, we currently prevent their use. The specifics around which callbacks are explicitly allowed are defined in [`BulkInsertSafe`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/models/concerns/bulk_insert_safe.rb). diff --git a/doc/development/kubernetes.md b/doc/development/kubernetes.md index 45c94019c63..a6d9c754838 100644 --- a/doc/development/kubernetes.md +++ b/doc/development/kubernetes.md @@ -136,7 +136,7 @@ Mitigation strategies include: 1. Not allowing redirects to attacker controller resources: [`Kubeclient::KubeClient`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/kubernetes/kube_client.rb#) - can be configured to disallow any redirects by passing in + can be configured to prevent any redirects by passing in `http_max_redirects: 0` as an option. 1. Not exposing error messages: by doing so, we prevent attackers from triggering errors to expose results from diff --git a/doc/development/snowplow/implementation.md b/doc/development/snowplow/implementation.md index d35413cfd5f..228fdff4413 100644 --- a/doc/development/snowplow/implementation.md +++ b/doc/development/snowplow/implementation.md @@ -520,7 +520,7 @@ To install and run Snowplow Micro, complete these steps to modify the ### Troubleshoot To control content security policy warnings when using an external host, modify `config/gitlab.yml` -to allow or disallow them. To allow them, add the relevant host for `connect_src`. For example, for +to allow or prevent them. To allow them, add the relevant host for `connect_src`. For example, for `https://snowplow.trx.gitlab.net`: ```yaml diff --git a/doc/integration/elasticsearch.md b/doc/integration/elasticsearch.md index 5912d460079..9385b5a8baf 100644 --- a/doc/integration/elasticsearch.md +++ b/doc/integration/elasticsearch.md @@ -662,7 +662,7 @@ Sidekiq processes](../administration/operations/extra_sidekiq_processes.md). ``` You can also use the `gitlab:elastic:clear_index_status` Rake task to force the - indexer to "forget" all progress, so it will retry the indexing process from the + indexer to "forget" all progress, so it retries the indexing process from the start. 1. Personal snippets are not associated with a project and need to be indexed separately: diff --git a/doc/security/two_factor_authentication.md b/doc/security/two_factor_authentication.md index e8bb627ccbd..d0842ddb103 100644 --- a/doc/security/two_factor_authentication.md +++ b/doc/security/two_factor_authentication.md @@ -74,7 +74,7 @@ The following are important notes about 2FA: 2FA enabled, 2FA is **not** required for those individually added members. - If there are multiple 2FA requirements (for example, group + all users, or multiple groups) the shortest grace period is used. -- It is possible to disallow subgroups from setting up their own 2FA requirements: +- It is possible to prevent subgroups from setting up their own 2FA requirements: 1. Go to the top-level group's **Settings > General**. 1. Expand the **Permissions and group features** section. 1. Uncheck the **Allow subgroups to set up their own two-factor authentication rule** field. diff --git a/doc/user/group/saml_sso/group_managed_accounts.md b/doc/user/group/saml_sso/group_managed_accounts.md index aeb7db923a9..bffaef40800 100644 --- a/doc/user/group/saml_sso/group_managed_accounts.md +++ b/doc/user/group/saml_sso/group_managed_accounts.md @@ -65,7 +65,7 @@ This restriction also applies to projects forked from or to those groups. > [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/34648) in GitLab 12.9. -Groups with group-managed accounts can disallow forking of projects to destinations outside the group. +Groups with group-managed accounts can prevent forking of projects to destinations outside the group. To do so, enable the "Prohibit outer forks" option in **Settings > SAML SSO**. When enabled **at the parent group level**, projects within the group can be forked only to other destinations within the group (including its subgroups). diff --git a/lib/api/ci/jobs.rb b/lib/api/ci/jobs.rb index 30ce1454419..6c03d854ccd 100644 --- a/lib/api/ci/jobs.rb +++ b/lib/api/ci/jobs.rb @@ -38,7 +38,7 @@ module API use :pagination end # rubocop: disable CodeReuse/ActiveRecord - get ':id/jobs', feature_category: :continuous_integration do + get ':id/jobs', urgency: :low, feature_category: :continuous_integration do authorize_read_builds! builds = user_project.builds.order('id DESC') @@ -55,7 +55,7 @@ module API params do requires :job_id, type: Integer, desc: 'The ID of a job' end - get ':id/jobs/:job_id', feature_category: :continuous_integration do + get ':id/jobs/:job_id', urgency: :low, feature_category: :continuous_integration do authorize_read_builds! build = find_build!(params[:job_id]) @@ -70,7 +70,7 @@ module API params do requires :job_id, type: Integer, desc: 'The ID of a job' end - get ':id/jobs/:job_id/trace', feature_category: :continuous_integration do + get ':id/jobs/:job_id/trace', urgency: :low, feature_category: :continuous_integration do authorize_read_builds! build = find_build!(params[:job_id]) @@ -92,7 +92,7 @@ module API params do requires :job_id, type: Integer, desc: 'The ID of a job' end - post ':id/jobs/:job_id/cancel', feature_category: :continuous_integration do + post ':id/jobs/:job_id/cancel', urgency: :low, feature_category: :continuous_integration do authorize_update_builds! build = find_build!(params[:job_id]) @@ -109,7 +109,7 @@ module API params do requires :job_id, type: Integer, desc: 'The ID of a build' end - post ':id/jobs/:job_id/retry', feature_category: :continuous_integration do + post ':id/jobs/:job_id/retry', urgency: :low, feature_category: :continuous_integration do authorize_update_builds! build = find_build!(params[:job_id]) @@ -127,7 +127,7 @@ module API params do requires :job_id, type: Integer, desc: 'The ID of a build' end - post ':id/jobs/:job_id/erase', feature_category: :continuous_integration do + post ':id/jobs/:job_id/erase', urgency: :low, feature_category: :continuous_integration do authorize_update_builds! build = find_build!(params[:job_id]) @@ -146,7 +146,7 @@ module API requires :job_id, type: Integer, desc: 'The ID of a Job' end - post ":id/jobs/:job_id/play", feature_category: :continuous_integration do + post ':id/jobs/:job_id/play', urgency: :low, feature_category: :continuous_integration do authorize_read_builds! job = find_job!(params[:job_id]) @@ -168,11 +168,11 @@ module API end resource :job do - desc 'Get current project using job token' do + desc 'Get current job using job token' do success Entities::Ci::Job end route_setting :authentication, job_token_allowed: true - get '', feature_category: :continuous_integration do + get '', feature_category: :continuous_integration, urgency: :low do validate_current_authenticated_job present current_authenticated_job, with: Entities::Ci::Job diff --git a/lib/api/ci/pipelines.rb b/lib/api/ci/pipelines.rb index e0086f624a8..6627d356108 100644 --- a/lib/api/ci/pipelines.rb +++ b/lib/api/ci/pipelines.rb @@ -123,7 +123,7 @@ module API use :pagination end - get ':id/pipelines/:pipeline_id/jobs', feature_category: :continuous_integration do + get ':id/pipelines/:pipeline_id/jobs', urgency: :low, feature_category: :continuous_integration do authorize!(:read_pipeline, user_project) pipeline = user_project.all_pipelines.find(params[:pipeline_id]) diff --git a/lib/api/ci/runner.rb b/lib/api/ci/runner.rb index 4aa244b997e..0e3b295396b 100644 --- a/lib/api/ci/runner.rb +++ b/lib/api/ci/runner.rb @@ -131,7 +131,7 @@ module API formatter :build_json, ->(object, _) { object } parser :build_json, ::Grape::Parser::Json - post '/request', feature_category: :continuous_integration do + post '/request', urgency: :low, feature_category: :continuous_integration do authenticate_runner! unless current_runner.active? @@ -185,7 +185,7 @@ module API end optional :exit_code, type: Integer, desc: %q(Job's exit code) end - put '/:id', feature_category: :continuous_integration do + put '/:id', urgency: :low, feature_category: :continuous_integration do job = authenticate_job!(heartbeat_runner: true) Gitlab::Metrics.add_event(:update_build) @@ -212,7 +212,7 @@ module API requires :id, type: Integer, desc: %q(Job's ID) optional :token, type: String, desc: %q(Job's authentication token) end - patch '/:id/trace', feature_category: :continuous_integration do + patch '/:id/trace', urgency: :default, feature_category: :continuous_integration do job = authenticate_job!(heartbeat_runner: true) error!('400 Missing header Content-Range', 400) unless request.headers.key?('Content-Range') diff --git a/lib/api/entities/wiki_page.rb b/lib/api/entities/wiki_page.rb index a8ef0bd857c..6944a5a785b 100644 --- a/lib/api/entities/wiki_page.rb +++ b/lib/api/entities/wiki_page.rb @@ -4,6 +4,10 @@ module API module Entities class WikiPage < WikiPageBasic expose :content + + expose :encoding do |wiki_page| + wiki_page.content.encoding.name + end end end end diff --git a/lib/gitlab/ci/config/external/file/local.rb b/lib/gitlab/ci/config/external/file/local.rb index fdb3e1b00f9..3839c43bd53 100644 --- a/lib/gitlab/ci/config/external/file/local.rb +++ b/lib/gitlab/ci/config/external/file/local.rb @@ -33,6 +33,10 @@ module Gitlab def fetch_local_content context.project.repository.blob_data_at(context.sha, location) + rescue GRPC::InvalidArgument + errors.push("Sha #{context.sha} is not valid!") + + nil end override :expand_context_attrs diff --git a/lib/gitlab/usage_data_counters/known_events/work_items.yml b/lib/gitlab/usage_data_counters/known_events/work_items.yml index a33a635b801..0c9c6026c46 100644 --- a/lib/gitlab/usage_data_counters/known_events/work_items.yml +++ b/lib/gitlab/usage_data_counters/known_events/work_items.yml @@ -4,3 +4,8 @@ redis_slot: users aggregation: weekly feature_flag: track_work_items_activity +- name: users_creating_work_items + category: work_items + redis_slot: users + aggregation: weekly + feature_flag: track_work_items_activity diff --git a/lib/gitlab/usage_data_counters/work_item_activity_unique_counter.rb b/lib/gitlab/usage_data_counters/work_item_activity_unique_counter.rb index 2d5ea0368fd..6f5300405c7 100644 --- a/lib/gitlab/usage_data_counters/work_item_activity_unique_counter.rb +++ b/lib/gitlab/usage_data_counters/work_item_activity_unique_counter.rb @@ -3,9 +3,14 @@ module Gitlab module UsageDataCounters module WorkItemActivityUniqueCounter + WORK_ITEM_CREATED = 'users_creating_work_items' WORK_ITEM_TITLE_CHANGED = 'users_updating_work_item_title' class << self + def track_work_item_created_action(author:) + track_unique_action(WORK_ITEM_CREATED, author) + end + def track_work_item_title_changed_action(author:) track_unique_action(WORK_ITEM_TITLE_CHANGED, author) end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index b08b69dc275..4b36479fc86 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -22972,9 +22972,6 @@ msgstr "" msgid "Merge request not merged" msgstr "" -msgid "Merge request pipelines are configured. A detached pipeline runs in the context of the merge request, and not against the merged result. Learn more in the documentation for merge request pipelines." -msgstr "" - msgid "Merge request reports" msgstr "" @@ -27017,6 +27014,12 @@ msgstr "" msgid "Pipelines|This is a child pipeline within the parent pipeline" msgstr "" +msgid "Pipelines|This pipeline ran on the contents of this merge request combined with the contents of all other merge requests queued for merging into the target branch." +msgstr "" + +msgid "Pipelines|This pipeline ran on the contents of this merge request's source branch, not the target branch." +msgstr "" + msgid "Pipelines|This pipeline will run code originating from a forked project merge request. This means that the code can potentially have security considerations like exposing CI variables." msgstr "" @@ -27059,9 +27062,6 @@ msgstr "" msgid "Pipelines|Your changes have been successfully committed. Now redirecting to the new merge request page." msgstr "" -msgid "Pipelines|detached" -msgstr "" - msgid "Pipelines|error" msgstr "" @@ -27071,10 +27071,13 @@ msgstr "" msgid "Pipelines|latest" msgstr "" -msgid "Pipelines|stuck" +msgid "Pipelines|merge request" msgstr "" -msgid "Pipelines|train" +msgid "Pipelines|merge train" +msgstr "" + +msgid "Pipelines|stuck" msgstr "" msgid "Pipelines|yaml invalid" @@ -27206,6 +27209,12 @@ msgstr "" msgid "Pipeline|This change will not change the overall test coverage if merged." msgstr "" +msgid "Pipeline|This pipeline ran on the contents of this merge request combined with the contents of all other merge requests queued for merging into the target branch." +msgstr "" + +msgid "Pipeline|This pipeline ran on the contents of this merge request's source branch, not the target branch." +msgstr "" + msgid "Pipeline|Trigger author" msgstr "" @@ -27230,6 +27239,12 @@ msgstr "" msgid "Pipeline|for" msgstr "" +msgid "Pipeline|merge request" +msgstr "" + +msgid "Pipeline|merge train" +msgstr "" + msgid "Pipeline|on" msgstr "" @@ -37452,9 +37467,6 @@ msgstr "" msgid "This is a list of devices that have logged into your account. Revoke any sessions that you do not recognize." msgstr "" -msgid "This is a merge train pipeline" -msgstr "" - msgid "This is a private email address %{helpIcon} generated just for you. Anyone who has it can create issues or merge requests as if they were you. If that happens, %{resetLinkStart}reset this token%{resetLinkEnd}." msgstr "" @@ -43290,9 +43302,6 @@ msgstr "" msgid "design" msgstr "" -msgid "detached" -msgstr "" - msgid "disabled" msgstr "" @@ -44448,9 +44457,6 @@ msgstr "" msgid "toggle collapse" msgstr "" -msgid "train" -msgstr "" - msgid "triggered" msgstr "" diff --git a/spec/features/dashboard/todos/todos_filtering_spec.rb b/spec/features/dashboard/todos/todos_filtering_spec.rb index 53209db3107..938e42623f6 100644 --- a/spec/features/dashboard/todos/todos_filtering_spec.rb +++ b/spec/features/dashboard/todos/todos_filtering_spec.rb @@ -178,7 +178,7 @@ RSpec.describe 'Dashboard > User filters todos', :js do review_requested: ' requested a review of ', mentioned: ' mentioned ', marked: ' added a todo for ', - build_failed: ' build failed for ' + build_failed: ' pipeline failed in ' } action_name_text = action_names.delete(action_name) diff --git a/spec/features/dashboard/todos/todos_spec.rb b/spec/features/dashboard/todos/todos_spec.rb index b00bdeac3b9..ef3032f30c9 100644 --- a/spec/features/dashboard/todos/todos_spec.rb +++ b/spec/features/dashboard/todos/todos_spec.rb @@ -400,7 +400,7 @@ RSpec.describe 'Dashboard Todos' do end it 'shows the todo' do - expect(page).to have_content 'The build failed for merge request' + expect(page).to have_content 'The pipeline failed in merge request' end it 'links to the pipelines for the merge request' do diff --git a/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb b/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb index 2a49109d360..09c6b6bce3b 100644 --- a/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb +++ b/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb @@ -25,6 +25,8 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', } end + let(:expected_detached_mr_tag) {'merge request'} + before do stub_application_setting(auto_devops_enabled: false) stub_ci_pipeline_yaml_file(YAML.dump(config)) @@ -118,16 +120,16 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', it 'sees detached tag for detached merge request pipelines' do page.within('.ci-table') do expect(all('.pipeline-tags')[0]) - .to have_content("detached") + .to have_content(expected_detached_mr_tag) expect(all('.pipeline-tags')[1]) - .to have_content("detached") + .to have_content(expected_detached_mr_tag) expect(all('.pipeline-tags')[2]) - .not_to have_content("detached") + .not_to have_content(expected_detached_mr_tag) expect(all('.pipeline-tags')[3]) - .not_to have_content("detached") + .not_to have_content(expected_detached_mr_tag) end end @@ -312,16 +314,16 @@ RSpec.describe 'Merge request > User sees pipelines triggered by merge request', it 'sees detached tag for detached merge request pipelines' do page.within('.ci-table') do expect(all('.pipeline-tags')[0]) - .to have_content("detached") + .to have_content(expected_detached_mr_tag) expect(all('.pipeline-tags')[1]) - .to have_content("detached") + .to have_content(expected_detached_mr_tag) expect(all('.pipeline-tags')[2]) - .not_to have_content("detached") + .not_to have_content(expected_detached_mr_tag) expect(all('.pipeline-tags')[3]) - .not_to have_content("detached") + .not_to have_content(expected_detached_mr_tag) end end diff --git a/spec/features/merge_request/user_sees_pipelines_spec.rb b/spec/features/merge_request/user_sees_pipelines_spec.rb index de960e36d50..77c21a250ff 100644 --- a/spec/features/merge_request/user_sees_pipelines_spec.rb +++ b/spec/features/merge_request/user_sees_pipelines_spec.rb @@ -186,7 +186,7 @@ RSpec.describe 'Merge request > User sees pipelines', :js do page.within(first('.commit')) do page.within('.pipeline-tags') do expect(page.find('[data-testid="pipeline-url-link"]')[:href]).to include(expected_project.full_path) - expect(page).to have_content('detached') + expect(page).to have_content('merge request') end page.within('.pipeline-triggerer') do expect(page).to have_link(href: user_path(actor)) diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 01c942aec4c..faa34cd4e17 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -1413,7 +1413,7 @@ RSpec.describe 'Pipeline', :js do it 'contains badge that indicates detached merge request pipeline' do page.within(all('.well-segment')[1]) do - expect(page).to have_content 'detached' + expect(page).to have_content 'merge request' end end end diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index e5138677eb2..c031942dbb3 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -7,6 +7,7 @@ RSpec.describe 'Pipelines', :js do include Spec::Support::Helpers::ModalHelpers let(:project) { create(:project) } + let(:expected_detached_mr_tag) {'merge request'} context 'when user is logged in' do let(:user) { create(:user) } @@ -181,7 +182,7 @@ RSpec.describe 'Pipelines', :js do shared_examples_for 'detached merge request pipeline' do it 'shows pipeline information without pipeline ref', :sidekiq_might_not_need_inline do within '.pipeline-tags' do - expect(page).to have_content('detached') + expect(page).to have_content(expected_detached_mr_tag) end within '.branch-commit' do @@ -225,7 +226,7 @@ RSpec.describe 'Pipelines', :js do shared_examples_for 'detached merge request pipeline' do it 'shows pipeline information without pipeline ref', :sidekiq_might_not_need_inline do within '.pipeline-tags' do - expect(page).to have_content('detached') + expect(page).to have_content(expected_detached_mr_tag) expect(page).to have_link(merge_request.iid, href: project_merge_request_path(project, merge_request)) @@ -266,7 +267,7 @@ RSpec.describe 'Pipelines', :js do shared_examples_for 'Correct merge request pipeline information' do it 'does not show detached tag for the pipeline, and shows the link of the merge request, and does not show the ref of the pipeline', :sidekiq_might_not_need_inline do within '.pipeline-tags' do - expect(page).not_to have_content('detached') + expect(page).not_to have_content(expected_detached_mr_tag) end within '.branch-commit' do @@ -311,7 +312,7 @@ RSpec.describe 'Pipelines', :js do shared_examples_for 'Correct merge request pipeline information' do it 'does not show detached tag for the pipeline, and shows the link of the merge request, and does not show the ref of the pipeline', :sidekiq_might_not_need_inline do within '.pipeline-tags' do - expect(page).not_to have_content('detached') + expect(page).not_to have_content(expected_detached_mr_tag) expect(page).to have_link(merge_request.iid, href: project_merge_request_path(project, merge_request)) diff --git a/spec/frontend/pipelines/pipeline_url_spec.js b/spec/frontend/pipelines/pipeline_url_spec.js index 2f083faaaa6..dd47195ec21 100644 --- a/spec/frontend/pipelines/pipeline_url_spec.js +++ b/spec/frontend/pipelines/pipeline_url_spec.js @@ -132,7 +132,7 @@ describe('Pipeline Url Component', () => { ...detachedMRPipeline, }); - expect(findDetachedTag().text()).toContain('detached'); + expect(findDetachedTag().text()).toBe('merge request'); }); it('should render error badge when pipeline has a failure reason set', () => { @@ -180,7 +180,7 @@ describe('Pipeline Url Component', () => { ...mergeTrainPipeline, }); - expect(findTrainTag().text()).toContain('train'); + expect(findTrainTag().text()).toBe('merge train'); }); it('should not render the train badge when the pipeline is not a merge train pipeline', () => { diff --git a/spec/graphql/resolvers/blobs_resolver_spec.rb b/spec/graphql/resolvers/blobs_resolver_spec.rb index bc0344796ee..ae5a83536ad 100644 --- a/spec/graphql/resolvers/blobs_resolver_spec.rb +++ b/spec/graphql/resolvers/blobs_resolver_spec.rb @@ -68,6 +68,28 @@ RSpec.describe Resolvers::BlobsResolver do ) end end + + context 'when specifying an invalid ref' do + let(:ref) { 'ma:in' } + + it 'raises an ArgumentError' do + expect { resolve_blobs }.to raise_error( + Gitlab::Graphql::Errors::ArgumentError, + 'Ref is not valid' + ) + end + end + + context 'when passing an empty ref' do + let(:ref) { '' } + + it 'raises an ArgumentError' do + expect { resolve_blobs }.to raise_error( + Gitlab::Graphql::Errors::ArgumentError, + 'Ref is not valid' + ) + end + end end end end diff --git a/spec/lib/api/entities/wiki_page_spec.rb b/spec/lib/api/entities/wiki_page_spec.rb new file mode 100644 index 00000000000..934fd43ad88 --- /dev/null +++ b/spec/lib/api/entities/wiki_page_spec.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe API::Entities::WikiPage do + let_it_be_with_reload(:wiki_page) { create(:wiki_page) } + + let(:entity) { described_class.new(wiki_page) } + + it 'returns the proper encoding for the wiki page content' do + expect(entity.as_json[:encoding]).to eq 'UTF-8' + + wiki_page.update_attributes(content: 'new_content'.encode('ISO-8859-1')) # rubocop:disable Rails/ActiveRecordAliases, Rails/SaveBang + + expect(entity.as_json[:encoding]).to eq 'ISO-8859-1' + end +end diff --git a/spec/lib/gitlab/ci/config/external/file/local_spec.rb b/spec/lib/gitlab/ci/config/external/file/local_spec.rb index 3d1fc32a62d..dec3eebe7b1 100644 --- a/spec/lib/gitlab/ci/config/external/file/local_spec.rb +++ b/spec/lib/gitlab/ci/config/external/file/local_spec.rb @@ -81,6 +81,16 @@ RSpec.describe Gitlab::Ci::Config::External::File::Local do expect(local_file.valid?).to be_falsy end end + + context 'when the given sha is not valid' do + let(:location) { '/lib/gitlab/ci/templates/existent-file.yml' } + let(:sha) { ':' } + + it 'returns false and adds an error message stating that included file does not exist' do + expect(local_file).not_to be_valid + expect(local_file.errors).to include("Sha #{sha} is not valid!") + end + end end describe '#content' do diff --git a/spec/lib/gitlab/usage_data_counters/work_item_activity_unique_counter_spec.rb b/spec/lib/gitlab/usage_data_counters/work_item_activity_unique_counter_spec.rb index abd5d29d7e6..4561d898479 100644 --- a/spec/lib/gitlab/usage_data_counters/work_item_activity_unique_counter_spec.rb +++ b/spec/lib/gitlab/usage_data_counters/work_item_activity_unique_counter_spec.rb @@ -17,16 +17,12 @@ RSpec.describe Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter, :clean_ end end - describe '.track_work_item_title_changed_action' do - subject(:track_event) { described_class.track_work_item_title_changed_action(author: user) } - - let(:event_name) { described_class::WORK_ITEM_TITLE_CHANGED } - + shared_examples 'work item unique counter' do context 'when track_work_items_activity FF is enabled' do it 'tracks a unique event only once' do expect { 3.times { track_event } }.to change { Gitlab::UsageDataCounters::HLLRedisCounter.unique_events( - event_names: described_class::WORK_ITEM_TITLE_CHANGED, + event_names: event_name, start_date: 2.weeks.ago, end_date: 2.weeks.from_now ) @@ -48,4 +44,20 @@ RSpec.describe Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter, :clean_ it_behaves_like 'counter that does not track the event' end end + + describe '.track_work_item_created_action' do + subject(:track_event) { described_class.track_work_item_created_action(author: user) } + + let(:event_name) { described_class::WORK_ITEM_CREATED } + + it_behaves_like 'work item unique counter' + end + + describe '.track_work_item_title_changed_action' do + subject(:track_event) { described_class.track_work_item_title_changed_action(author: user) } + + let(:event_name) { described_class::WORK_ITEM_TITLE_CHANGED } + + it_behaves_like 'work item unique counter' + end end diff --git a/spec/models/work_item_spec.rb b/spec/models/work_item_spec.rb index 2fa1abda44a..e92ae746911 100644 --- a/spec/models/work_item_spec.rb +++ b/spec/models/work_item_spec.rb @@ -10,4 +10,16 @@ RSpec.describe WorkItem do expect(work_item.noteable_target_type_name).to eq('issue') end end + + describe 'callbacks' do + describe 'record_create_action' do + it 'records the creation action after saving' do + expect(Gitlab::UsageDataCounters::WorkItemActivityUniqueCounter).to receive(:track_work_item_created_action) + # During the work item transition we also want to track work items as issues + expect(Gitlab::UsageDataCounters::IssueActivityUniqueCounter).to receive(:track_issue_created_action) + + create(:work_item) + end + end + end end diff --git a/spec/requests/api/wikis_spec.rb b/spec/requests/api/wikis_spec.rb index ec34dc7e7a1..7f44ba1d796 100644 --- a/spec/requests/api/wikis_spec.rb +++ b/spec/requests/api/wikis_spec.rb @@ -31,7 +31,7 @@ RSpec.describe API::Wikis do let(:project_wiki) { create(:project_wiki, project: project, user: user) } let(:payload) { { content: 'content', format: 'rdoc', title: 'title' } } - let(:expected_keys_with_content) { %w(content format slug title) } + let(:expected_keys_with_content) { %w(content format slug title encoding) } let(:expected_keys_without_content) { %w(format slug title) } let(:wiki) { project_wiki } diff --git a/spec/support/shared_examples/lib/wikis_api_examples.rb b/spec/support/shared_examples/lib/wikis_api_examples.rb index 2e4c667d37e..8008daf2eb9 100644 --- a/spec/support/shared_examples/lib/wikis_api_examples.rb +++ b/spec/support/shared_examples/lib/wikis_api_examples.rb @@ -46,11 +46,12 @@ end RSpec.shared_examples_for 'wikis API returns wiki page' do it 'returns the wiki page' do expect(response).to have_gitlab_http_status(:ok) - expect(json_response.size).to eq(4) + expect(json_response.size).to eq(5) expect(json_response.keys).to match_array(expected_keys_with_content) expect(json_response['content']).to eq(page.content) expect(json_response['slug']).to eq(page.slug) expect(json_response['title']).to eq(page.title) + expect(json_response['encoding']).to eq('UTF-8') end end @@ -59,12 +60,13 @@ RSpec.shared_examples_for 'wikis API creates wiki page' do post(api(url, user), params: payload) expect(response).to have_gitlab_http_status(:created) - expect(json_response.size).to eq(4) + expect(json_response.size).to eq(5) expect(json_response.keys).to match_array(expected_keys_with_content) expect(json_response['content']).to eq(payload[:content]) expect(json_response['slug']).to eq(payload[:title].tr(' ', '-')) expect(json_response['title']).to eq(payload[:title]) expect(json_response['rdoc']).to eq(payload[:rdoc]) + expect(json_response['encoding']).to eq('UTF-8') end [:title, :content].each do |part| @@ -85,7 +87,7 @@ RSpec.shared_examples_for 'wikis API updates wiki page' do put(api(url, user), params: payload) expect(response).to have_gitlab_http_status(:ok) - expect(json_response.size).to eq(4) + expect(json_response.size).to eq(5) expect(json_response.keys).to match_array(expected_keys_with_content) expect(json_response['content']).to eq(payload[:content]) expect(json_response['slug']).to eq(payload[:title].tr(' ', '-'))