Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
e679ecfe1d
commit
4fed8ce9c8
2
Gemfile
2
Gemfile
|
|
@ -360,7 +360,7 @@ group :development, :test do
|
|||
|
||||
gem 'database_cleaner', '~> 1.7.0'
|
||||
gem 'factory_bot_rails', '~> 5.1.0'
|
||||
gem 'rspec-rails', '~> 4.0.0'
|
||||
gem 'rspec-rails', '~> 4.0.1'
|
||||
|
||||
# Prevent occasions where minitest is not bundled in packaged versions of ruby (see #3826)
|
||||
gem 'minitest', '~> 5.11.0'
|
||||
|
|
|
|||
28
Gemfile.lock
28
Gemfile.lock
|
|
@ -252,7 +252,7 @@ GEM
|
|||
devise (~> 4.0)
|
||||
railties (< 6.1)
|
||||
rotp (~> 2.0)
|
||||
diff-lcs (1.3)
|
||||
diff-lcs (1.4.4)
|
||||
diff_match_patch (0.1.0)
|
||||
diffy (3.3.0)
|
||||
discordrb-webhooks-blackst0ne (3.3.0)
|
||||
|
|
@ -989,25 +989,25 @@ GEM
|
|||
chunky_png
|
||||
rqrcode-rails3 (0.1.7)
|
||||
rqrcode (>= 0.4.2)
|
||||
rspec (3.9.0)
|
||||
rspec-core (~> 3.9.0)
|
||||
rspec-expectations (~> 3.9.0)
|
||||
rspec-mocks (~> 3.9.0)
|
||||
rspec-core (3.9.1)
|
||||
rspec-support (~> 3.9.1)
|
||||
rspec-expectations (3.9.1)
|
||||
rspec (3.10.0)
|
||||
rspec-core (~> 3.10.0)
|
||||
rspec-expectations (~> 3.10.0)
|
||||
rspec-mocks (~> 3.10.0)
|
||||
rspec-core (3.10.0)
|
||||
rspec-support (~> 3.10.0)
|
||||
rspec-expectations (3.10.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-mocks (3.9.1)
|
||||
rspec-support (~> 3.10.0)
|
||||
rspec-mocks (3.10.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.9.0)
|
||||
rspec-support (~> 3.10.0)
|
||||
rspec-parameterized (0.4.2)
|
||||
binding_ninja (>= 0.2.3)
|
||||
parser
|
||||
proc_to_ast
|
||||
rspec (>= 2.13, < 4)
|
||||
unparser
|
||||
rspec-rails (4.0.0)
|
||||
rspec-rails (4.0.1)
|
||||
actionpack (>= 4.2)
|
||||
activesupport (>= 4.2)
|
||||
railties (>= 4.2)
|
||||
|
|
@ -1017,7 +1017,7 @@ GEM
|
|||
rspec-support (~> 3.9)
|
||||
rspec-retry (0.6.1)
|
||||
rspec-core (> 3.3)
|
||||
rspec-support (3.9.2)
|
||||
rspec-support (3.10.0)
|
||||
rspec_junit_formatter (0.4.1)
|
||||
rspec-core (>= 2, < 4, != 2.12.0)
|
||||
rspec_profiling (0.0.6)
|
||||
|
|
@ -1481,7 +1481,7 @@ DEPENDENCIES
|
|||
rouge (~> 3.26.0)
|
||||
rqrcode-rails3 (~> 0.1.7)
|
||||
rspec-parameterized
|
||||
rspec-rails (~> 4.0.0)
|
||||
rspec-rails (~> 4.0.1)
|
||||
rspec-retry (~> 0.6.1)
|
||||
rspec_junit_formatter
|
||||
rspec_profiling (~> 0.0.6)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ export default {
|
|||
};
|
||||
</script>
|
||||
<template>
|
||||
<gl-button-group>
|
||||
<gl-button-group data-qa-selector="default_actions_container">
|
||||
<gl-button
|
||||
v-if="!hasRenderError"
|
||||
v-gl-tooltip.hover
|
||||
|
|
@ -59,6 +59,7 @@ export default {
|
|||
:disabled="copyDisabled"
|
||||
:data-clipboard-target="getBlobHashTarget"
|
||||
data-testid="copyContentsButton"
|
||||
data-qa-selector="copy_contents_button"
|
||||
icon="copy-to-clipboard"
|
||||
category="primary"
|
||||
variant="default"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
|
|||
|
||||
around_action :allow_gitaly_ref_name_caching
|
||||
|
||||
after_action :track_viewed_diffs_events, only: [:diffs_batch]
|
||||
|
||||
def show
|
||||
render_diffs
|
||||
end
|
||||
|
|
@ -188,4 +190,16 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
|
|||
|
||||
Discussions::CaptureDiffNotePositionsService.new(@merge_request).execute
|
||||
end
|
||||
|
||||
def track_viewed_diffs_events
|
||||
return if request.headers['DNT'] == '1'
|
||||
|
||||
Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter
|
||||
.track_mr_diffs_action(merge_request: @merge_request)
|
||||
|
||||
return unless current_user&.view_diffs_file_by_file
|
||||
|
||||
Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter
|
||||
.track_mr_diffs_single_file_action(merge_request: @merge_request, user: current_user)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
module Clusters
|
||||
module Applications
|
||||
class Runner < ApplicationRecord
|
||||
VERSION = '0.23.0'
|
||||
VERSION = '0.24.0'
|
||||
|
||||
self.table_name = 'clusters_applications_runners'
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ module MergeRequests
|
|||
return error('Failed to update schedule.') unless update_schedule
|
||||
|
||||
success
|
||||
rescue Gitlab::Git::Repository::GitError, Gitlab::Git::CommandError => e
|
||||
error(e.message)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -18,6 +18,6 @@
|
|||
- unless group.has_parent?
|
||||
.form-group
|
||||
.form-check
|
||||
= f.check_box :allow_mfa_for_subgroups, class: 'form-check-input', checked: group.namespace_settings.allow_mfa_for_subgroups
|
||||
= f.check_box :allow_mfa_for_subgroups, class: 'form-check-input', checked: group.namespace_settings&.allow_mfa_for_subgroups
|
||||
= f.label :allow_mfa_for_subgroups, class: 'form-check-label' do
|
||||
= _('Allow subgroups to set up their own two-factor authentication rules')
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Instrument viewing merge request diffs file by file
|
||||
merge_request: 48470
|
||||
author:
|
||||
type: added
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Handle git errors when cleaning up MR refs
|
||||
merge_request: 50250
|
||||
author:
|
||||
type: fixed
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Update GitLab Runner Helm Chart to 0.24.0
|
||||
merge_request: 50377
|
||||
author:
|
||||
type: other
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
name: usage_data_i_code_review_mr_diffs
|
||||
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48470
|
||||
rollout_issue_url:
|
||||
milestone: '13.7'
|
||||
type: development
|
||||
group: group::code review
|
||||
default_enabled: true
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
name: usage_data_i_code_review_mr_single_file_diffs
|
||||
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48470
|
||||
rollout_issue_url:
|
||||
milestone: '13.7'
|
||||
type: development
|
||||
group: group::code review
|
||||
default_enabled: true
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
name: usage_data_i_code_review_user_single_file_diffs
|
||||
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48470
|
||||
rollout_issue_url:
|
||||
milestone: '13.7'
|
||||
type: development
|
||||
group: group::code review
|
||||
default_enabled: true
|
||||
|
|
@ -113,6 +113,7 @@ class Gitlab::Seeder::Projects
|
|||
group.save!
|
||||
|
||||
group.add_owner(User.first)
|
||||
group.create_namespace_settings
|
||||
end
|
||||
|
||||
project_path.gsub!(".git", "")
|
||||
|
|
|
|||
|
|
@ -15,9 +15,10 @@ For data objects such as LFS, Uploads, Artifacts, etc., an [Object Storage servi
|
|||
is recommended over NFS where possible, due to better performance.
|
||||
|
||||
WARNING:
|
||||
From GitLab 13.0, using NFS for Git repositories is deprecated. In GitLab 14.0,
|
||||
support for NFS for Git repositories is scheduled to be removed. Upgrade to
|
||||
[Gitaly Cluster](gitaly/praefect.md) as soon as possible.
|
||||
From GitLab 13.0, using NFS for Git repositories is deprecated.
|
||||
From GitLab 14.0, technical support for NFS for Git repositories
|
||||
will no longer be provided. Upgrade to [Gitaly Cluster](gitaly/praefect.md)
|
||||
as soon as possible.
|
||||
|
||||
Filesystem performance can impact overall GitLab performance, especially for
|
||||
actions that read or write to Git repositories. For steps you can use to test
|
||||
|
|
|
|||
|
|
@ -2125,6 +2125,12 @@ to use GitLab Pages, this currently [requires NFS](troubleshooting.md#gitlab-pag
|
|||
|
||||
See how to [configure NFS](../nfs.md).
|
||||
|
||||
WARNING:
|
||||
From GitLab 13.0, using NFS for Git repositories is deprecated.
|
||||
From GitLab 14.0, technical support for NFS for Git repositories
|
||||
will no longer be provided. Upgrade to [Gitaly Cluster](../gitaly/praefect.md)
|
||||
as soon as possible.
|
||||
|
||||
<div align="right">
|
||||
<a type="button" class="btn btn-default" href="#setup-components">
|
||||
Back to setup components <i class="fa fa-angle-double-up" aria-hidden="true"></i>
|
||||
|
|
|
|||
|
|
@ -2125,6 +2125,12 @@ to use GitLab Pages, this currently [requires NFS](troubleshooting.md#gitlab-pag
|
|||
|
||||
See how to [configure NFS](../nfs.md).
|
||||
|
||||
WARNING:
|
||||
From GitLab 13.0, using NFS for Git repositories is deprecated.
|
||||
From GitLab 14.0, technical support for NFS for Git repositories
|
||||
will no longer be provided. Upgrade to [Gitaly Cluster](../gitaly/praefect.md)
|
||||
as soon as possible.
|
||||
|
||||
<div align="right">
|
||||
<a type="button" class="btn btn-default" href="#setup-components">
|
||||
Back to setup components <i class="fa fa-angle-double-up" aria-hidden="true"></i>
|
||||
|
|
|
|||
|
|
@ -954,7 +954,13 @@ along with [Gitaly](#configure-gitaly), are recommended over using NFS whenever
|
|||
possible. However, if you intend to use GitLab Pages,
|
||||
[you must use NFS](troubleshooting.md#gitlab-pages-requires-nfs).
|
||||
|
||||
For information about configuring NFS, see the [NFS documentation page](../nfs.md).
|
||||
See how to [configure NFS](../nfs.md).
|
||||
|
||||
WARNING:
|
||||
From GitLab 13.0, using NFS for Git repositories is deprecated.
|
||||
From GitLab 14.0, technical support for NFS for Git repositories
|
||||
will no longer be provided. Upgrade to [Gitaly Cluster](../gitaly/praefect.md)
|
||||
as soon as possible.
|
||||
|
||||
<div align="right">
|
||||
<a type="button" class="btn btn-default" href="#setup-components">
|
||||
|
|
|
|||
|
|
@ -1843,6 +1843,12 @@ to use GitLab Pages, this currently [requires NFS](troubleshooting.md#gitlab-pag
|
|||
|
||||
See how to [configure NFS](../nfs.md).
|
||||
|
||||
WARNING:
|
||||
From GitLab 13.0, using NFS for Git repositories is deprecated.
|
||||
From GitLab 14.0, technical support for NFS for Git repositories
|
||||
will no longer be provided. Upgrade to [Gitaly Cluster](../gitaly/praefect.md)
|
||||
as soon as possible.
|
||||
|
||||
<div align="right">
|
||||
<a type="button" class="btn btn-default" href="#setup-components">
|
||||
Back to setup components <i class="fa fa-angle-double-up" aria-hidden="true"></i>
|
||||
|
|
|
|||
|
|
@ -2125,6 +2125,12 @@ to use GitLab Pages, this currently [requires NFS](troubleshooting.md#gitlab-pag
|
|||
|
||||
See how to [configure NFS](../nfs.md).
|
||||
|
||||
WARNING:
|
||||
From GitLab 13.0, using NFS for Git repositories is deprecated.
|
||||
From GitLab 14.0, technical support for NFS for Git repositories
|
||||
will no longer be provided. Upgrade to [Gitaly Cluster](../gitaly/praefect.md)
|
||||
as soon as possible.
|
||||
|
||||
<div align="right">
|
||||
<a type="button" class="btn btn-default" href="#setup-components">
|
||||
Back to setup components <i class="fa fa-angle-double-up" aria-hidden="true"></i>
|
||||
|
|
|
|||
|
|
@ -1841,6 +1841,12 @@ to use GitLab Pages, this currently [requires NFS](troubleshooting.md#gitlab-pag
|
|||
|
||||
See how to [configure NFS](../nfs.md).
|
||||
|
||||
WARNING:
|
||||
From GitLab 13.0, using NFS for Git repositories is deprecated.
|
||||
From GitLab 14.0, technical support for NFS for Git repositories
|
||||
will no longer be provided. Upgrade to [Gitaly Cluster](../gitaly/praefect.md)
|
||||
as soon as possible.
|
||||
|
||||
<div align="right">
|
||||
<a type="button" class="btn btn-default" href="#setup-components">
|
||||
Back to setup components <i class="fa fa-angle-double-up" aria-hidden="true"></i>
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ with the Fog library that GitLab uses. Symptoms include:
|
|||
### GitLab Pages requires NFS
|
||||
|
||||
If you intend to use [GitLab Pages](../../user/project/pages/index.md), this currently requires
|
||||
[NFS](../nfs.md). There is [work in progress](https://gitlab.com/gitlab-org/gitlab-pages/-/issues/196)
|
||||
to remove this dependency. In the future, GitLab Pages may use
|
||||
[object storage](https://gitlab.com/gitlab-org/gitlab/-/issues/208135).
|
||||
[NFS](../nfs.md). There is [work in progress](https://gitlab.com/groups/gitlab-org/-/epics/3901)
|
||||
to remove this dependency. In the future, GitLab Pages will use
|
||||
object storage.
|
||||
|
||||
The dependency on disk storage also prevents Pages being deployed using the
|
||||
[GitLab Helm chart](https://gitlab.com/gitlab-org/charts/gitlab/-/issues/37).
|
||||
[GitLab Helm chart](https://gitlab.com/groups/gitlab-org/-/epics/4283).
|
||||
|
||||
### Incremental logging is required for CI to use object storage
|
||||
|
||||
|
|
|
|||
|
|
@ -425,3 +425,18 @@
|
|||
redis_slot: snippets
|
||||
aggregation: weekly
|
||||
feature_flag: usage_data_i_snippets_show
|
||||
- name: i_code_review_mr_diffs
|
||||
redis_slot: code_review
|
||||
category: code_review
|
||||
aggregation: weekly
|
||||
feature_flag: usage_data_i_code_review_mr_diffs
|
||||
- name: i_code_review_user_single_file_diffs
|
||||
redis_slot: code_review
|
||||
category: code_review
|
||||
aggregation: weekly
|
||||
feature_flag: usage_data_i_code_review_user_single_file_diffs
|
||||
- name: i_code_review_mr_single_file_diffs
|
||||
redis_slot: code_review
|
||||
category: code_review
|
||||
aggregation: weekly
|
||||
feature_flag: usage_data_i_code_review_mr_single_file_diffs
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Gitlab
|
||||
module UsageDataCounters
|
||||
module MergeRequestActivityUniqueCounter
|
||||
MR_DIFFS_ACTION = 'i_code_review_mr_diffs'
|
||||
MR_DIFFS_SINGLE_FILE_ACTION = 'i_code_review_mr_single_file_diffs'
|
||||
MR_DIFFS_USER_SINGLE_FILE_ACTION = 'i_code_review_user_single_file_diffs'
|
||||
|
||||
class << self
|
||||
def track_mr_diffs_action(merge_request:)
|
||||
track_unique_action_by_merge_request(MR_DIFFS_ACTION, merge_request)
|
||||
end
|
||||
|
||||
def track_mr_diffs_single_file_action(merge_request:, user:)
|
||||
track_unique_action_by_merge_request(MR_DIFFS_SINGLE_FILE_ACTION, merge_request)
|
||||
track_unique_action_by_user(MR_DIFFS_USER_SINGLE_FILE_ACTION, user)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def track_unique_action_by_merge_request(action, merge_request)
|
||||
track_unique_action(action, merge_request.id)
|
||||
end
|
||||
|
||||
def track_unique_action_by_user(action, user)
|
||||
return unless user
|
||||
|
||||
track_unique_action(action, user.id)
|
||||
end
|
||||
|
||||
def track_unique_action(action, value)
|
||||
Gitlab::UsageDataCounters::HLLRedisCounter.track_usage_event(action, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -78,6 +78,11 @@ module QA
|
|||
base.view 'app/assets/javascripts/snippets/components/embed_dropdown.vue' do
|
||||
element :copy_button
|
||||
end
|
||||
|
||||
base.view 'app/assets/javascripts/blob/components/blob_header_default_actions.vue' do
|
||||
element :default_actions_container
|
||||
element :copy_contents_button
|
||||
end
|
||||
end
|
||||
|
||||
def has_snippet_title?(snippet_title)
|
||||
|
|
@ -182,7 +187,10 @@ module QA
|
|||
def add_comment(comment)
|
||||
fill_element(:note_field, comment)
|
||||
click_element(:comment_button)
|
||||
wait_until(reload: false) { has_element?(:note_author_content) }
|
||||
|
||||
unless has_element?(:note_author_content)
|
||||
raise ElementNotFound, "Comment did not appear as expected"
|
||||
end
|
||||
end
|
||||
|
||||
def has_comment_author?(author_username)
|
||||
|
|
@ -207,7 +215,10 @@ module QA
|
|||
click_element(:edit_comment_button)
|
||||
fill_element(:edit_note_field, comment)
|
||||
click_element(:save_comment_button)
|
||||
wait_until(reload: false) { has_element?(:note_author_content) }
|
||||
|
||||
unless has_element?(:note_author_content)
|
||||
raise ElementNotFound, "Comment did not appear as expected"
|
||||
end
|
||||
end
|
||||
|
||||
def delete_comment(comment)
|
||||
|
|
@ -215,7 +226,32 @@ module QA
|
|||
accept_alert do
|
||||
click_element(:delete_comment_button)
|
||||
end
|
||||
wait_until(reload: false) { has_no_text?(comment) }
|
||||
|
||||
unless has_no_element?(:note_content, text: comment)
|
||||
raise ElementNotFound, "Comment was not removed as expected"
|
||||
end
|
||||
end
|
||||
|
||||
def click_copy_file_contents(file_number = nil)
|
||||
if file_number
|
||||
within_element_by_index(:default_actions_container, file_number - 1) do
|
||||
click_element(:copy_contents_button)
|
||||
end
|
||||
else
|
||||
within_element(:default_actions_container) do
|
||||
click_element(:copy_contents_button)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def copy_file_contents_to_comment(file_number = nil)
|
||||
click_copy_file_contents(file_number)
|
||||
send_keys_to_element(:note_field, [:shift, :insert])
|
||||
click_element(:comment_button)
|
||||
|
||||
unless has_element?(:note_author_content)
|
||||
raise ElementNotFound, "Comment did not appear as expected"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module QA
|
||||
RSpec.describe 'Create' do
|
||||
describe 'Multiple file snippet' do
|
||||
let(:first_file_content) { 'First file content' }
|
||||
let(:second_file_content) { 'Second file content' }
|
||||
let(:third_file_content) { 'Third file content' }
|
||||
|
||||
let(:personal_snippet) do
|
||||
Resource::Snippet.fabricate_via_api! do |snippet|
|
||||
snippet.title = 'Personal snippet to copy file contents from'
|
||||
snippet.file_name = 'First file name'
|
||||
snippet.file_content = first_file_content
|
||||
|
||||
snippet.add_files do |files|
|
||||
files.append(name: 'Second file name', content: second_file_content)
|
||||
files.append(name: 'Third file name', content: third_file_content)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
let(:project_snippet) do
|
||||
Resource::ProjectSnippet.fabricate_via_api! do |snippet|
|
||||
snippet.title = 'Project snippet to copy file contents from'
|
||||
snippet.file_name = 'First file name'
|
||||
snippet.file_content = first_file_content
|
||||
|
||||
snippet.add_files do |files|
|
||||
files.append(name: 'Second file name', content: second_file_content)
|
||||
files.append(name: 'Third file name', content: third_file_content)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
let(:files) do
|
||||
[
|
||||
{
|
||||
number: 1,
|
||||
content: first_file_content
|
||||
},
|
||||
{
|
||||
number: 2,
|
||||
content: second_file_content
|
||||
},
|
||||
{
|
||||
number: 3,
|
||||
content: third_file_content
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
before do
|
||||
Flow::Login.sign_in
|
||||
end
|
||||
|
||||
shared_examples 'copying snippet file contents' do |snippet_type|
|
||||
it "copies file contents of a multi-file #{snippet_type} to a comment and verifies them" do
|
||||
send(snippet_type).visit!
|
||||
|
||||
files.each do |files|
|
||||
Page::Dashboard::Snippet::Show.perform do |snippet|
|
||||
snippet.copy_file_contents_to_comment(files[:number])
|
||||
expect(snippet).to have_comment_content(files[:content])
|
||||
snippet.delete_comment(files[:content])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like 'copying snippet file contents', :personal_snippet
|
||||
it_behaves_like 'copying snippet file contents', :project_snippet
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -7,7 +7,7 @@ module QA
|
|||
Resource::Snippet.fabricate! do |snippet|
|
||||
snippet.title = 'Shared snippet'
|
||||
snippet.visibility = 'Public'
|
||||
snippet.file_content = 'code.py'
|
||||
snippet.file_name = 'code.py'
|
||||
snippet.file_content = 'code to be shared'
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -378,6 +378,57 @@ RSpec.describe Projects::MergeRequests::DiffsController do
|
|||
|
||||
expect(response).to have_gitlab_http_status(:ok)
|
||||
end
|
||||
|
||||
it 'tracks mr_diffs event' do
|
||||
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
|
||||
.to receive(:track_mr_diffs_action)
|
||||
.with(merge_request: merge_request)
|
||||
|
||||
subject
|
||||
end
|
||||
|
||||
context 'when DNT is enabled' do
|
||||
before do
|
||||
request.headers['DNT'] = '1'
|
||||
end
|
||||
|
||||
it 'does not track any mr_diffs event' do
|
||||
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
|
||||
.not_to receive(:track_mr_diffs_action)
|
||||
|
||||
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
|
||||
.not_to receive(:track_mr_diffs_single_file_action)
|
||||
|
||||
subject
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user has view_diffs_file_by_file set to false' do
|
||||
before do
|
||||
user.update!(view_diffs_file_by_file: false)
|
||||
end
|
||||
|
||||
it 'does not track single_file_diffs events' do
|
||||
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
|
||||
.not_to receive(:track_mr_diffs_single_file_action)
|
||||
|
||||
subject
|
||||
end
|
||||
end
|
||||
|
||||
context 'when user has view_diffs_file_by_file set to true' do
|
||||
before do
|
||||
user.update!(view_diffs_file_by_file: true)
|
||||
end
|
||||
|
||||
it 'tracks single_file_diffs events' do
|
||||
expect(Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter)
|
||||
.to receive(:track_mr_diffs_single_file_action)
|
||||
.with(merge_request: merge_request, user: user)
|
||||
|
||||
subject
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def collection_arguments(pagination_data = {})
|
||||
|
|
|
|||
|
|
@ -45,7 +45,8 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
|
|||
'debian_packages',
|
||||
'container_packages',
|
||||
'tag_packages',
|
||||
'snippets'
|
||||
'snippets',
|
||||
'code_review'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
RSpec.describe Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter, :clean_gitlab_redis_shared_state do
|
||||
let(:merge_request) { build(:merge_request, id: 1) }
|
||||
let(:user) { build(:user, id: 1) }
|
||||
|
||||
shared_examples_for 'a tracked merge request unique event' do
|
||||
specify do
|
||||
expect { 3.times { subject } }
|
||||
.to change {
|
||||
Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(
|
||||
event_names: action,
|
||||
start_date: 2.weeks.ago,
|
||||
end_date: 2.weeks.from_now
|
||||
)
|
||||
}
|
||||
.by(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe '.track_mr_diffs_action' do
|
||||
subject { described_class.track_mr_diffs_action(merge_request: merge_request) }
|
||||
|
||||
it_behaves_like 'a tracked merge request unique event' do
|
||||
let(:action) { described_class::MR_DIFFS_ACTION }
|
||||
end
|
||||
end
|
||||
|
||||
describe '.track_mr_diffs_single_file_action' do
|
||||
subject { described_class.track_mr_diffs_single_file_action(merge_request: merge_request, user: user) }
|
||||
|
||||
it_behaves_like 'a tracked merge request unique event' do
|
||||
let(:action) { described_class::MR_DIFFS_SINGLE_FILE_ACTION }
|
||||
end
|
||||
|
||||
it_behaves_like 'a tracked merge request unique event' do
|
||||
let(:action) { described_class::MR_DIFFS_USER_SINGLE_FILE_ACTION }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -91,6 +91,26 @@ RSpec.describe MergeRequests::CleanupRefsService do
|
|||
it_behaves_like 'service that does not clean up merge request refs'
|
||||
end
|
||||
|
||||
context 'when a git error is raised' do
|
||||
context 'Gitlab::Git::Repository::GitError' do
|
||||
before do
|
||||
allow(merge_request.project.repository).to receive(:delete_refs).and_raise(Gitlab::Git::Repository::GitError)
|
||||
end
|
||||
|
||||
it_behaves_like 'service that does not clean up merge request refs'
|
||||
end
|
||||
|
||||
context 'Gitlab::Git::CommandError' do
|
||||
before do
|
||||
allow_next_instance_of(Gitlab::Git::KeepAround) do |keep_around|
|
||||
expect(keep_around).to receive(:kept_around?).and_raise(Gitlab::Git::CommandError)
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like 'service that does not clean up merge request refs'
|
||||
end
|
||||
end
|
||||
|
||||
context 'when cleanup schedule fails to update' do
|
||||
before do
|
||||
allow(merge_request.cleanup_schedule).to receive(:update).and_return(false)
|
||||
|
|
|
|||
Loading…
Reference in New Issue