diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-12 09:10:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-12 09:10:21 +0000 |
commit | 135059c00cbc56fd7b7fdc2a6a87c7a94fe64649 (patch) | |
tree | 201a6143cde92c27c87f87c2ab3139cdec91fcf4 | |
parent | de9b52d3bba0b5720c9b27df5058eabbe832fe49 (diff) | |
download | gitlab-ce-135059c00cbc56fd7b7fdc2a6a87c7a94fe64649.tar.gz |
Add latest changes from gitlab-org/gitlab@master
24 files changed, 150 insertions, 177 deletions
diff --git a/app/assets/javascripts/sidebar/components/reviewers/reviewer_title.vue b/app/assets/javascripts/sidebar/components/reviewers/reviewer_title.vue index 933b9b11b40..55bb214aa65 100644 --- a/app/assets/javascripts/sidebar/components/reviewers/reviewer_title.vue +++ b/app/assets/javascripts/sidebar/components/reviewers/reviewer_title.vue @@ -43,6 +43,7 @@ export default { data-track-action="click_edit_button" data-track-label="right_sidebar" data-track-property="reviewer" + data-qa-selector="reviewers_edit_button" > {{ __('Edit') }} </a> diff --git a/app/assets/javascripts/vue_shared/components/markdown/apply_suggestion.vue b/app/assets/javascripts/vue_shared/components/markdown/apply_suggestion.vue index 926034efd10..caec49c557a 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/apply_suggestion.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/apply_suggestion.vue @@ -51,6 +51,7 @@ export default { <gl-dropdown :text="dropdownText" :disabled="disabled" + size="small" boundary="window" right lazy diff --git a/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_header.vue b/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_header.vue index 7646a8718d6..855c7a449c4 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_header.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_header.vue @@ -139,7 +139,7 @@ export default { </script> <template> - <div class="md-suggestion-header border-bottom-0 gl-mt-3"> + <div class="md-suggestion-header border-bottom-0 gl-px-4 gl-py-3"> <div class="js-suggestion-diff-header gl-font-weight-bold"> {{ __('Suggested change') }} <a v-if="helpPagePath" :href="helpPagePath" :aria-label="__('Help')" class="js-help-btn"> @@ -162,6 +162,7 @@ export default { <gl-button class="btn-inverted js-remove-from-batch-btn btn-grouped" :disabled="isApplying" + size="small" @click="removeSuggestionFromBatch" > {{ __('Remove from batch') }} @@ -172,6 +173,7 @@ export default { class="btn-inverted js-add-to-batch-btn btn-grouped" data-qa-selector="add_suggestion_batch_button" :disabled="isDisableButton" + size="small" @click="addSuggestionToBatch" > {{ __('Add suggestion to batch') }} diff --git a/app/assets/stylesheets/framework/markdown_area.scss b/app/assets/stylesheets/framework/markdown_area.scss index 24055e6e8de..c40cadafb9c 100644 --- a/app/assets/stylesheets/framework/markdown_area.scss +++ b/app/assets/stylesheets/framework/markdown_area.scss @@ -149,8 +149,16 @@ .md-suggestion-diff { display: table !important; border: 1px solid $border-color !important; - width: 100% !important; - font-family: $monospace-font !important; + + td { + border: 0 !important; + } + + tr.old { + td { + border-radius: 0 !important; + } + } } .suggestions.md > .markdown-code-block { @@ -158,23 +166,12 @@ } .md-suggestion-header { - height: $suggestion-header-height; display: flex; align-items: center; justify-content: space-between; background-color: $gray-light; border: 1px solid $border-color; - padding: $gl-padding; border-radius: $border-radius-default $border-radius-default 0 0; - - svg { - vertical-align: middle; - margin-bottom: 3px; - } - - .dropdown-chevron { - margin-bottom: 0; - } } @include media-breakpoint-down(xs) { diff --git a/app/assets/stylesheets/framework/variables.scss b/app/assets/stylesheets/framework/variables.scss index 5a590d2393b..9cfc5a0201e 100644 --- a/app/assets/stylesheets/framework/variables.scss +++ b/app/assets/stylesheets/framework/variables.scss @@ -442,7 +442,6 @@ $browser-scrollbar-size: 10px; $header-height: var(--header-height, 48px); $header-zindex: 1000; $zindex-dropdown-menu: 300; -$suggestion-header-height: 46px; $ide-statusbar-height: 25px; $fixed-layout-width: 1280px; $limited-layout-width: 990px; diff --git a/app/views/groups/projects.html.haml b/app/views/groups/projects.html.haml index d5511c2cb49..e7ae54a8879 100644 --- a/app/views/groups/projects.html.haml +++ b/app/views/groups/projects.html.haml @@ -5,12 +5,11 @@ = render Pajamas::CardComponent.new(card_options: { class: 'gl-mt-3 js-search-settings-section' }, header_options: { class: 'gl-display-flex' }, body_options: { class: 'gl-py-0' }) do |c| - c.header do .gl-flex-grow-1 - %strong= @group.name - projects: + = html_escape(_("%{strong_open}%{group_name}%{strong_close} projects:")) % { strong_open: '<strong>'.html_safe, group_name: @group.name, strong_close: '</strong>'.html_safe } - if can? current_user, :admin_group, @group .controls - = link_to new_project_path(namespace_id: @group.id), class: "btn gl-button btn-sm btn-confirm" do - New project + = render Pajamas::ButtonComponent.new(href: new_project_path(namespace_id: @group.id), size: :small, variant: :confirm) do + = _("New project") - c.body do %ul.content-list - @projects.each do |project| @@ -43,6 +42,6 @@ = link_to _('Edit'), edit_project_path(project), id: dom_id(project, :edit), class: "btn gl-button" = render 'delete_project_button', project: project - if @projects.blank? - .nothing-here-block This group has no projects yet + .nothing-here-block= _("This group has no projects yet") = paginate @projects, theme: "gitlab" diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml index f2ce0676a9a..281623bdd3c 100644 --- a/app/views/shared/issuable/_sidebar.html.haml +++ b/app/views/shared/issuable/_sidebar.html.haml @@ -27,7 +27,7 @@ #js-severity - if reviewers - .block.reviewer + .block.reviewer{ data: { qa_selector: 'reviewers_block_container' } } = render "shared/issuable/sidebar_reviewers", issuable_sidebar: issuable_sidebar, reviewers: reviewers, signed_in: signed_in - if issuable_sidebar[:supports_escalation] diff --git a/config/feature_flags/development/wiki_find_page_with_normal_repository_rpcs.yml b/config/feature_flags/development/wiki_find_page_with_normal_repository_rpcs.yml index bad0578d50a..31d98265984 100644 --- a/config/feature_flags/development/wiki_find_page_with_normal_repository_rpcs.yml +++ b/config/feature_flags/development/wiki_find_page_with_normal_repository_rpcs.yml @@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/371487 milestone: '15.4' type: development group: group::gitaly -default_enabled: false +default_enabled: true diff --git a/config/feature_flags/development/wiki_list_pages_with_normal_repository_rpcs.yml b/config/feature_flags/development/wiki_list_pages_with_normal_repository_rpcs.yml index 4be550b5046..aaa5bb4abff 100644 --- a/config/feature_flags/development/wiki_list_pages_with_normal_repository_rpcs.yml +++ b/config/feature_flags/development/wiki_list_pages_with_normal_repository_rpcs.yml @@ -5,4 +5,4 @@ rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/372259 milestone: '15.4' type: development group: group::gitaly -default_enabled: false +default_enabled: true diff --git a/doc/ci/yaml/index.md b/doc/ci/yaml/index.md index 054a100574b..938d70c73a5 100644 --- a/doc/ci/yaml/index.md +++ b/doc/ci/yaml/index.md @@ -1238,7 +1238,11 @@ is not found, the prefix is added to `default`, so the key in the example would #### `cache:untracked` -Use `untracked: true` to cache all files that are untracked in your Git repository: +Use `untracked: true` to cache all files that are untracked in your Git repository. +Untracked files include files that are: + +- Ignored due to [`.gitignore` configuration](https://git-scm.com/docs/gitignore). +- Created, but not added to the checkout with [`git add`](https://git-scm.com/docs/git-add). **Keyword type**: Job keyword. You can use it only as part of a job or in the [`default` section](#default). @@ -1259,7 +1263,7 @@ rspec: **Additional details**: - You can combine `cache:untracked` with `cache:paths` to cache all untracked files - as well as files in the configured paths. For example: + as well as files in the configured paths. This is useful for including files that are not tracked because of a `.gitignore` configuration. For example: ```yaml rspec: diff --git a/doc/user/packages/container_registry/index.md b/doc/user/packages/container_registry/index.md index 28675e949cd..4ce0618ba9f 100644 --- a/doc/user/packages/container_registry/index.md +++ b/doc/user/packages/container_registry/index.md @@ -101,12 +101,14 @@ registry.example.com/mynamespace/myproject/my/image:rc1 ## Authenticate with the Container Registry -To authenticate with the Container Registry, you can use: +To authenticate with the Container Registry, you can use a: -- A [personal access token](../../profile/personal_access_tokens.md). -- A [deploy token](../../project/deploy_tokens/index.md). +- [Personal access token](../../profile/personal_access_tokens.md). +- [Deploy token](../../project/deploy_tokens/index.md). +- [Project access token](../../project/settings/project_access_tokens.md). +- [Group access token](../../group/settings/group_access_tokens.md). -Both of these require the minimum scope to be: +All of these require the minimum scope to be: - For read (pull) access, `read_registry`. - For write (push) access, `write_registry` & `read_registry`. diff --git a/doc/user/project/pages/public_folder.md b/doc/user/project/pages/public_folder.md index ae0575c5ce6..1ec467c2ac5 100644 --- a/doc/user/project/pages/public_folder.md +++ b/doc/user/project/pages/public_folder.md @@ -54,12 +54,12 @@ rename that folder to a collision-free alternative first: export default { // GitLab Pages requires exposed files to be located in a folder called "public". // So we're instructing Astro to put the static build output in a folder of that name. - dist: 'public', + outDir: 'public', // The folder name Astro uses for static files (`public`) is already reserved // for the build output. So in deviation from the defaults we're using a folder // called `static` instead. - public: 'static', + publicDir: 'static', }; ``` diff --git a/lib/gitlab/ci/templates/Pages/Harp.gitlab-ci.yml b/lib/gitlab/ci/templates/Pages/Harp.gitlab-ci.yml index 9e48ac9fcdc..aa86ad2a6ad 100644 --- a/lib/gitlab/ci/templates/Pages/Harp.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Pages/Harp.gitlab-ci.yml @@ -18,3 +18,4 @@ pages: - public rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + environment: production diff --git a/lib/gitlab/ci/templates/Pages/Hugo.gitlab-ci.yml b/lib/gitlab/ci/templates/Pages/Hugo.gitlab-ci.yml index 591eebf9cd6..d6f6e94526e 100644 --- a/lib/gitlab/ci/templates/Pages/Hugo.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Pages/Hugo.gitlab-ci.yml @@ -27,3 +27,4 @@ pages: only: variables: - $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + environment: production diff --git a/lib/gitlab/ci/templates/Pages/Metalsmith.gitlab-ci.yml b/lib/gitlab/ci/templates/Pages/Metalsmith.gitlab-ci.yml index d97f0b7beb7..a49e95b62c8 100644 --- a/lib/gitlab/ci/templates/Pages/Metalsmith.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Pages/Metalsmith.gitlab-ci.yml @@ -19,3 +19,4 @@ pages: - public rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + environment: production diff --git a/lib/gitlab/ci/templates/Pages/Middleman.gitlab-ci.yml b/lib/gitlab/ci/templates/Pages/Middleman.gitlab-ci.yml index 17ce0ef3659..d8f036ab4ed 100644 --- a/lib/gitlab/ci/templates/Pages/Middleman.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Pages/Middleman.gitlab-ci.yml @@ -31,3 +31,4 @@ pages: - public rules: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + environment: production diff --git a/lib/gitlab/ci/templates/Pages/Pelican.gitlab-ci.yml b/lib/gitlab/ci/templates/Pages/Pelican.gitlab-ci.yml index 7d52a407848..3721344b21e 100644 --- a/lib/gitlab/ci/templates/Pages/Pelican.gitlab-ci.yml +++ b/lib/gitlab/ci/templates/Pages/Pelican.gitlab-ci.yml @@ -13,3 +13,4 @@ pages: artifacts: paths: - public/ + environment: production diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 69eb3e05004..f5194a421f9 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -1040,6 +1040,9 @@ msgstr[1] "" msgid "%{strongStart}Tip:%{strongEnd} You can also check out merge requests locally. %{linkStart}Learn more.%{linkEnd}" msgstr "" +msgid "%{strong_open}%{group_name}%{strong_close} projects:" +msgstr "" + msgid "%{strong_start}%{branch_count}%{strong_end} Branch" msgid_plural "%{strong_start}%{branch_count}%{strong_end} Branches" msgstr[0] "" @@ -41103,6 +41106,9 @@ msgstr "" msgid "This group has no active access tokens." msgstr "" +msgid "This group has no projects yet" +msgstr "" + msgid "This group is linked to a subscription" msgstr "" diff --git a/qa/qa/page/component/issuable/sidebar.rb b/qa/qa/page/component/issuable/sidebar.rb index 68da89dc81d..71a69576c06 100644 --- a/qa/qa/page/component/issuable/sidebar.rb +++ b/qa/qa/page/component/issuable/sidebar.rb @@ -18,6 +18,10 @@ module QA element :more_assignees_link end + base.view 'app/assets/javascripts/sidebar/components/reviewers/reviewer_title.vue' do + element :reviewers_edit_button + end + base.view 'app/assets/javascripts/vue_shared/components/sidebar/labels_select_widget/labels_select_root.vue' do element :labels_block end @@ -37,6 +41,7 @@ module QA base.view 'app/views/shared/issuable/_sidebar.html.haml' do element :assignee_block_container element :milestone_block + element :reviewers_block_container end base.view 'app/assets/javascripts/sidebar/components/sidebar_dropdown_widget.vue' do @@ -46,6 +51,10 @@ module QA base.view 'app/assets/javascripts/sidebar/components/sidebar_editable_item.vue' do element :edit_link end + + base.view 'app/helpers/dropdowns_helper.rb' do + element :dropdown_list_content + end end def assign_milestone(milestone) diff --git a/qa/qa/resource/issuable.rb b/qa/qa/resource/issuable.rb new file mode 100644 index 00000000000..6ebdaac8298 --- /dev/null +++ b/qa/qa/resource/issuable.rb @@ -0,0 +1,79 @@ +# frozen_string_literal: true + +module QA + module Resource + class Issuable < Base + # Commentes (notes) path + # + # @return [String] + def api_comments_path + "#{api_get_path}/notes" + end + + # Get issue comments + # + # @return [Array] + def comments(auto_paginate: false, attempts: 0) + return parse_body(api_get_from(api_comments_path)) unless auto_paginate + + auto_paginated_response( + Runtime::API::Request.new(api_client, api_comments_path, per_page: '100').url, + attempts: attempts + ) + end + + # Create a new comment + # + # @param [String] body + # @param [Boolean] confidential + # @return [Hash] + def add_comment(body:, confidential: false) + api_post_to(api_comments_path, body: body, confidential: confidential) + end + + # Issue label events + # + # @param [Boolean] auto_paginate + # @param [Integer] attempts + # @return [Array<Hash>] + def label_events(auto_paginate: false, attempts: 0) + events("label", auto_paginate: auto_paginate, attempts: attempts) + end + + # Issue state events + # + # @param [Boolean] auto_paginate + # @param [Integer] attempts + # @return [Array<Hash>] + def state_events(auto_paginate: false, attempts: 0) + events("state", auto_paginate: auto_paginate, attempts: attempts) + end + + # Issue milestone events + # + # @param [Boolean] auto_paginate + # @param [Integer] attempts + # @return [Array<Hash>] + def milestone_events(auto_paginate: false, attempts: 0) + events("milestone", auto_paginate: auto_paginate, attempts: attempts) + end + + private + + # Issue events + # + # @param [String] name event name + # @param [Boolean] auto_paginate + # @param [Integer] attempts + # @return [Array<Hash>] + def events(name, auto_paginate:, attempts:) + return parse_body(api_get_from("#{api_get_path}/resource_#{name}_events")) unless auto_paginate + + auto_paginated_response( + Runtime::API::Request.new(api_client, "#{api_get_path}/resource_#{name}_events", per_page: '100').url, + attempts: attempts + ) + end + end + end +end diff --git a/qa/qa/resource/issue.rb b/qa/qa/resource/issue.rb index 40e2e819c99..2e18e1d0323 100644 --- a/qa/qa/resource/issue.rb +++ b/qa/qa/resource/issue.rb @@ -2,7 +2,7 @@ module QA module Resource - class Issue < Base + class Issue < Issuable attr_writer :milestone, :template, :weight attribute :project do @@ -53,10 +53,6 @@ module QA "/projects/#{project.id}/issues/#{iid}" end - def api_comments_path - "#{api_get_path}/notes" - end - def api_post_body { assignee_ids: assignee_ids, @@ -83,54 +79,6 @@ module QA QA::Runtime::Logger.debug("Successfully updated issue assignees to #{assignee_ids}") end - # Get issue comments - # - # @return [Array] - def comments(auto_paginate: false, attempts: 0) - return parse_body(api_get_from(api_comments_path)) unless auto_paginate - - auto_paginated_response( - Runtime::API::Request.new(api_client, api_comments_path, per_page: '100').url, - attempts: attempts - ) - end - - # Create a new comment - # - # @param [String] body - # @param [Boolean] confidential - # @return [Hash] - def add_comment(body:, confidential: false) - api_post_to(api_comments_path, body: body, confidential: confidential) - end - - # Issue label events - # - # @param [Boolean] auto_paginate - # @param [Integer] attempts - # @return [Array<Hash>] - def label_events(auto_paginate: false, attempts: 0) - events("label", auto_paginate: auto_paginate, attempts: attempts) - end - - # Issue state events - # - # @param [Boolean] auto_paginate - # @param [Integer] attempts - # @return [Array<Hash>] - def state_events(auto_paginate: false, attempts: 0) - events("state", auto_paginate: auto_paginate, attempts: attempts) - end - - # Issue milestone events - # - # @param [Boolean] auto_paginate - # @param [Integer] attempts - # @return [Array<Hash>] - def milestone_events(auto_paginate: false, attempts: 0) - events("milestone", auto_paginate: auto_paginate, attempts: attempts) - end - protected # Return subset of fields for comparing issues @@ -161,23 +109,6 @@ module QA :created_at ) end - - private - - # Issue events - # - # @param [String] name event name - # @param [Boolean] auto_paginate - # @param [Integer] attempts - # @return [Array<Hash>] - def events(name, auto_paginate:, attempts:) - return parse_body(api_get_from("#{api_get_path}/resource_#{name}_events")) unless auto_paginate - - auto_paginated_response( - Runtime::API::Request.new(api_client, "#{api_get_path}/resource_#{name}_events", per_page: '100').url, - attempts: attempts - ) - end end end end diff --git a/qa/qa/resource/merge_request.rb b/qa/qa/resource/merge_request.rb index e4314c4dae7..5d6dc12ac9c 100644 --- a/qa/qa/resource/merge_request.rb +++ b/qa/qa/resource/merge_request.rb @@ -2,7 +2,7 @@ module QA module Resource - class MergeRequest < Base + class MergeRequest < Issuable attr_accessor :approval_rules, :source_branch, :target_new_branch, @@ -130,10 +130,6 @@ module QA } end - def api_comments_path - "#{api_get_path}/notes" - end - def merge_via_api! Support::Waiter.wait_until(sleep_interval: 1) do QA::Runtime::Logger.debug("Waiting until merge request with id '#{iid}' can be merged") @@ -166,53 +162,6 @@ module QA current_url end - # Get MR comments - # - # @return [Array] - def comments(auto_paginate: false, attempts: 0) - return parse_body(api_get_from(api_comments_path)) unless auto_paginate - - auto_paginated_response( - Runtime::API::Request.new(api_client, api_comments_path, per_page: '100').url, - attempts: attempts - ) - end - - # Add mr comment - # - # @param [String] body - # @return [Hash] - def add_comment(body) - api_post_to(api_comments_path, body: body) - end - - # Merge request label events - # - # @param [Boolean] auto_paginate - # @param [Integer] attempts - # @return [Array<Hash>] - def label_events(auto_paginate: false, attempts: 0) - events("label", auto_paginate: auto_paginate, attempts: attempts) - end - - # Merge request state events - # - # @param [Boolean] auto_paginate - # @param [Integer] attempts - # @return [Array<Hash>] - def state_events(auto_paginate: false, attempts: 0) - events("state", auto_paginate: auto_paginate, attempts: attempts) - end - - # Merge request milestone events - # - # @param [Boolean] auto_paginate - # @param [Integer] attempts - # @return [Array<Hash>] - def milestone_events(auto_paginate: false, attempts: 0) - events("milestone", auto_paginate: auto_paginate, attempts: attempts) - end - # Return subset of fields for comparing merge requests # # @return [Hash] @@ -266,21 +215,6 @@ module QA def create_target? !(project.initialize_with_readme && target_branch == project.default_branch) && target_new_branch end - - # Merge request events - # - # @param [String] name event name - # @param [Boolean] auto_paginate - # @param [Integer] attempts - # @return [Array<Hash>] - def events(name, auto_paginate:, attempts:) - return parse_body(api_get_from("#{api_get_path}/resource_#{name}_events")) unless auto_paginate - - auto_paginated_response( - Runtime::API::Request.new(api_client, "#{api_get_path}/resource_#{name}_events", per_page: '100').url, - attempts: attempts - ) - end end end end diff --git a/spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb b/spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb index 09ac71d8ae8..a6c024be698 100644 --- a/spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb +++ b/spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb @@ -8,10 +8,11 @@ RSpec.describe 'Merge request > User sees avatars on diff notes', :js do include Spec::Support::Helpers::ModalHelpers include MergeRequestDiffHelpers - let(:project) { create(:project, :public, :repository) } - let(:user) { project.creator } - let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user, title: 'Bug NS-04') } - let(:path) { 'files/ruby/popen.rb' } + let_it_be(:project) { create(:project, :public, :repository) } + let_it_be(:user) { project.creator } + let_it_be(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user, title: 'Bug NS-04') } + + let(:path) { 'files/ruby/popen.rb' } let(:position) do build(:text_diff_position, :added, file: path, @@ -22,8 +23,11 @@ RSpec.describe 'Merge request > User sees avatars on diff notes', :js do let!(:note) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: position) } - before do + before_all do project.add_maintainer(user) + end + + before do sign_in user set_cookie('sidebar_collapsed', 'true') diff --git a/spec/lib/gitlab/usage/metrics/instrumentations/aggregated_metric_spec.rb b/spec/lib/gitlab/usage/metrics/instrumentations/aggregated_metric_spec.rb index 71e947df3ef..3e7b13e21c1 100644 --- a/spec/lib/gitlab/usage/metrics/instrumentations/aggregated_metric_spec.rb +++ b/spec/lib/gitlab/usage/metrics/instrumentations/aggregated_metric_spec.rb @@ -39,11 +39,12 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::AggregatedMetric, :clea 'redis_hll' | '28d' | 'OR' | 3 'redis_hll' | '7d' | 'AND' | 1 'redis_hll' | '7d' | 'OR' | 2 - 'database' | '7d' | 'OR' | 3 - 'database' | '7d' | 'AND' | 1 + 'database' | '7d' | 'OR' | 3.0 + 'database' | '7d' | 'AND' | 1.0 end with_them do + let(:error_rate) { Gitlab::Database::PostgresHll::BatchDistinctCounter::ERROR_RATE } let(:metric_definition) do { data_source: data_source, @@ -65,8 +66,7 @@ RSpec.describe Gitlab::Usage::Metrics::Instrumentations::AggregatedMetric, :clea end it 'has correct value' do - # database source is providing estimated value that have a lot of decimal places, round it for convenience - expect(described_class.new(metric_definition).value.round).to eq(expected_value) + expect(described_class.new(metric_definition).value).to be_within(error_rate).percent_of(expected_value) end end end |