diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-01 12:08:37 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-01 12:08:37 +0000 |
commit | 098ec8c914f61780b33bb18e929e25ef59dfb175 (patch) | |
tree | 0c30ccc7d6488fec2c7610aed1b10e364b5c64df | |
parent | f5eabcfa0e39e8212eb333d9e824294d14f530d5 (diff) | |
download | gitlab-ce-098ec8c914f61780b33bb18e929e25ef59dfb175.tar.gz |
Add latest changes from gitlab-org/gitlab@master
28 files changed, 159 insertions, 107 deletions
diff --git a/app/assets/javascripts/diffs/store/actions.js b/app/assets/javascripts/diffs/store/actions.js index 330ff8f8f83..66510edf3db 100644 --- a/app/assets/javascripts/diffs/store/actions.js +++ b/app/assets/javascripts/diffs/store/actions.js @@ -580,7 +580,7 @@ export const setShowWhitespace = async ( { state, commit }, { url, showWhitespace, updateDatabase = true }, ) => { - if (updateDatabase) { + if (updateDatabase && Boolean(window.gon?.current_user_id)) { await axios.put(url || state.endpointUpdateUser, { show_whitespace_in_diffs: showWhitespace }); } diff --git a/app/assets/javascripts/editor/constants.js b/app/assets/javascripts/editor/constants.js index bf3ca4d0c77..849ff91841a 100644 --- a/app/assets/javascripts/editor/constants.js +++ b/app/assets/javascripts/editor/constants.js @@ -1,3 +1,4 @@ +import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; import { __ } from '~/locale'; export const SOURCE_EDITOR_INSTANCE_ERROR_NO_EL = __( @@ -5,7 +6,7 @@ export const SOURCE_EDITOR_INSTANCE_ERROR_NO_EL = __( ); export const URI_PREFIX = 'gitlab'; -export const CONTENT_UPDATE_DEBOUNCE = 250; +export const CONTENT_UPDATE_DEBOUNCE = DEFAULT_DEBOUNCE_AND_THROTTLE_MS; export const ERROR_INSTANCE_REQUIRED_FOR_EXTENSION = __( 'Source Editor instance is required to set up an extension.', diff --git a/app/assets/javascripts/ide/lib/diff/controller.js b/app/assets/javascripts/ide/lib/diff/controller.js index 1d051062637..682914df9ec 100644 --- a/app/assets/javascripts/ide/lib/diff/controller.js +++ b/app/assets/javascripts/ide/lib/diff/controller.js @@ -1,5 +1,6 @@ import { throttle } from 'lodash'; import { Range } from 'monaco-editor'; +import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; import Disposable from '../common/disposable'; import DirtyDiffWorker from './diff_worker'; @@ -31,7 +32,7 @@ export default class DirtyDiffController { this.modelManager = modelManager; this.decorationsController = decorationsController; this.dirtyDiffWorker = new DirtyDiffWorker(); - this.throttledComputeDiff = throttle(this.computeDiff, 250); + this.throttledComputeDiff = throttle(this.computeDiff, DEFAULT_DEBOUNCE_AND_THROTTLE_MS); this.decorate = this.decorate.bind(this); this.dirtyDiffWorker.addEventListener('message', this.decorate); diff --git a/app/assets/javascripts/lib/utils/constants.js b/app/assets/javascripts/lib/utils/constants.js index 2d4765f54b9..e41de72ded4 100644 --- a/app/assets/javascripts/lib/utils/constants.js +++ b/app/assets/javascripts/lib/utils/constants.js @@ -1,4 +1,5 @@ export const BYTES_IN_KIB = 1024; +export const DEFAULT_DEBOUNCE_AND_THROTTLE_MS = 250; export const HIDDEN_CLASS = 'hidden'; export const TRUNCATE_WIDTH_DEFAULT_WIDTH = 80; export const TRUNCATE_WIDTH_DEFAULT_FONT_SIZE = 12; diff --git a/app/assets/javascripts/pages/admin/broadcast_messages/broadcast_message.js b/app/assets/javascripts/pages/admin/broadcast_messages/broadcast_message.js index 14f79294ea7..2a7e6a45cdd 100644 --- a/app/assets/javascripts/pages/admin/broadcast_messages/broadcast_message.js +++ b/app/assets/javascripts/pages/admin/broadcast_messages/broadcast_message.js @@ -3,6 +3,7 @@ import { debounce } from 'lodash'; import createFlash from '~/flash'; import axios from '~/lib/utils/axios_utils'; import { textColorForBackground } from '~/lib/utils/color_utils'; +import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; import { __ } from '~/locale'; export default () => { @@ -65,7 +66,7 @@ export default () => { 'input', debounce(() => { reloadPreview(); - }, 250), + }, DEFAULT_DEBOUNCE_AND_THROTTLE_MS), ); const updateColorPreview = () => { diff --git a/app/assets/javascripts/pipeline_new/constants.js b/app/assets/javascripts/pipeline_new/constants.js index 91a064a0fb8..a6c9f3cb746 100644 --- a/app/assets/javascripts/pipeline_new/constants.js +++ b/app/assets/javascripts/pipeline_new/constants.js @@ -1,6 +1,8 @@ +import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; + export const VARIABLE_TYPE = 'env_var'; export const FILE_TYPE = 'file'; -export const DEBOUNCE_REFS_SEARCH_MS = 250; +export const DEBOUNCE_REFS_SEARCH_MS = DEFAULT_DEBOUNCE_AND_THROTTLE_MS; export const CONFIG_VARIABLES_TIMEOUT = 5000; export const BRANCH_REF_TYPE = 'branch'; export const TAG_REF_TYPE = 'tag'; diff --git a/app/assets/javascripts/ref/constants.js b/app/assets/javascripts/ref/constants.js index 44d0f50b832..1cef986a83d 100644 --- a/app/assets/javascripts/ref/constants.js +++ b/app/assets/javascripts/ref/constants.js @@ -1,3 +1,4 @@ +import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; import { __ } from '~/locale'; export const REF_TYPE_BRANCHES = 'REF_TYPE_BRANCHES'; @@ -7,7 +8,7 @@ export const ALL_REF_TYPES = Object.freeze([REF_TYPE_BRANCHES, REF_TYPE_TAGS, RE export const X_TOTAL_HEADER = 'x-total'; -export const SEARCH_DEBOUNCE_MS = 250; +export const SEARCH_DEBOUNCE_MS = DEFAULT_DEBOUNCE_AND_THROTTLE_MS; export const DEFAULT_I18N = Object.freeze({ dropdownHeader: __('Select Git revision'), diff --git a/app/assets/javascripts/search_autocomplete.js b/app/assets/javascripts/search_autocomplete.js index 9c133a79607..0cec406c21a 100644 --- a/app/assets/javascripts/search_autocomplete.js +++ b/app/assets/javascripts/search_autocomplete.js @@ -4,6 +4,7 @@ import $ from 'jquery'; import { escape, throttle } from 'lodash'; import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown'; import { getIdenticonBackgroundClass, getIdenticonTitle } from '~/helpers/avatar_helper'; +import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; import { s__, __, sprintf } from '~/locale'; import Tracking from '~/tracking'; import axios from './lib/utils/axios_utils'; @@ -343,7 +344,10 @@ export class SearchAutocomplete { this.searchInput.on('focus', this.onSearchInputFocus); this.searchInput.on('blur', this.onSearchInputBlur); this.clearInput.on('click', this.onClearInputClick); - this.dropdownContent.on('scroll', throttle(this.setScrollFade, 250)); + this.dropdownContent.on( + 'scroll', + throttle(this.setScrollFade, DEFAULT_DEBOUNCE_AND_THROTTLE_MS), + ); this.searchInput.on('click', (e) => { e.stopPropagation(); diff --git a/app/assets/javascripts/sidebar/constants.js b/app/assets/javascripts/sidebar/constants.js index 12c69504483..c8c63310347 100644 --- a/app/assets/javascripts/sidebar/constants.js +++ b/app/assets/javascripts/sidebar/constants.js @@ -1,4 +1,5 @@ import { IssuableType } from '~/issue_show/constants'; +import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; import epicConfidentialQuery from '~/sidebar/queries/epic_confidential.query.graphql'; import epicDueDateQuery from '~/sidebar/queries/epic_due_date.query.graphql'; import epicParticipantsQuery from '~/sidebar/queries/epic_participants.query.graphql'; @@ -38,7 +39,7 @@ import projectIssueMilestoneMutation from './queries/project_issue_milestone.mut import projectIssueMilestoneQuery from './queries/project_issue_milestone.query.graphql'; import projectMilestonesQuery from './queries/project_milestones.query.graphql'; -export const ASSIGNEES_DEBOUNCE_DELAY = 250; +export const ASSIGNEES_DEBOUNCE_DELAY = DEFAULT_DEBOUNCE_AND_THROTTLE_MS; export const defaultEpicSort = 'TITLE_ASC'; diff --git a/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue b/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue index f1230e2fdeb..5e401fc17e9 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/mr_widget_header.vue @@ -1,16 +1,17 @@ <script> -/* eslint-disable vue/no-v-html */ import { GlButton, GlDropdown, GlDropdownSectionHeader, GlDropdownItem, + GlLink, GlTooltipDirective, GlModalDirective, + GlSafeHtmlDirective as SafeHtml, + GlSprintf, } from '@gitlab/ui'; -import { escape } from 'lodash'; import { mergeUrlParams, webIDEUrl } from '~/lib/utils/url_utility'; -import { n__, s__, sprintf } from '~/locale'; +import { s__ } from '~/locale'; import clipboardButton from '~/vue_shared/components/clipboard_button.vue'; import TooltipOnTruncate from '~/vue_shared/components/tooltip_on_truncate.vue'; import MrWidgetHowToMergeModal from './mr_widget_how_to_merge_modal.vue'; @@ -27,10 +28,13 @@ export default { GlDropdown, GlDropdownSectionHeader, GlDropdownItem, + GlLink, + GlSprintf, }, directives: { GlTooltip: GlTooltipDirective, GlModalDirective, + SafeHtml, }, props: { mr: { @@ -42,19 +46,6 @@ export default { shouldShowCommitsBehindText() { return this.mr.divergedCommitsCount > 0; }, - commitsBehindText() { - return sprintf( - s__( - 'mrWidget|The source branch is %{commitsBehindLinkStart}%{commitsBehind}%{commitsBehindLinkEnd} the target branch', - ), - { - commitsBehindLinkStart: `<a href="${escape(this.mr.targetBranchPath)}">`, - commitsBehind: n__('%d commit behind', '%d commits behind', this.mr.divergedCommitsCount), - commitsBehindLinkEnd: '</a>', - }, - false, - ); - }, branchNameClipboardData() { // This supports code in app/assets/javascripts/copy_to_clipboard.js that // works around ClipboardJS limitations to allow the context-specific @@ -100,10 +91,10 @@ export default { <strong> {{ s__('mrWidget|Request to merge') }} <tooltip-on-truncate + v-safe-html="mr.sourceBranchLink" :title="mr.sourceBranch" truncate-target="child" class="label-branch label-truncate js-source-branch" - v-html="mr.sourceBranchLink" /><clipboard-button data-testid="mr-widget-copy-clipboard" :text="branchNameClipboardData" @@ -119,11 +110,15 @@ export default { <a :href="mr.targetBranchTreePath" class="js-target-branch"> {{ mr.targetBranch }} </a> </tooltip-on-truncate> </strong> - <div - v-if="shouldShowCommitsBehindText" - class="diverged-commits-count" - v-html="commitsBehindText" - ></div> + <div v-if="shouldShowCommitsBehindText" class="diverged-commits-count"> + <gl-sprintf :message="s__('mrWidget|The source branch is %{link} the target branch')"> + <template #link> + <gl-link :href="mr.targetBranchPath">{{ + n__('%d commit behind', '%d commits behind', mr.divergedCommitsCount) + }}</gl-link> + </template> + </gl-sprintf> + </div> </div> <div class="branch-actions d-flex"> diff --git a/doc/administration/gitaly/index.md b/doc/administration/gitaly/index.md index 911faf40780..a1f66246603 100644 --- a/doc/administration/gitaly/index.md +++ b/doc/administration/gitaly/index.md @@ -185,7 +185,9 @@ In this example: - Repositories are stored on a virtual storage called `storage-1`. - Three Gitaly nodes provide `storage-1` access: `gitaly-1`, `gitaly-2`, and `gitaly-3`. -- The three Gitaly nodes store data on their file systems. +- The three Gitaly nodes share data in three separate hashed storage locations. +- The [replication factor](praefect.md#replication-factor) is `3`. There are three copies maintained + of each repository. ### Virtual storage or direct Gitaly storage @@ -206,9 +208,7 @@ In this example: - Each repository is stored on one of three Gitaly storages: `storage-1`, `storage-2`, or `storage-3`. - Each storage is serviced by a Gitaly node. -- The three Gitaly nodes share data in three separate hashed storage locations. -- The [replication factor](praefect.md#replication-factor) is `3`. There are three copies maintained - of each repository. +- The three Gitaly nodes store data on their file systems. Generally, virtual storage with Gitaly Cluster can replace direct Gitaly storage configurations, at the expense of additional storage needed to store each repository on multiple Gitaly nodes. The diff --git a/doc/development/dangerbot.md b/doc/development/dangerbot.md index d8ee95177f6..808ae22bb9e 100644 --- a/doc/development/dangerbot.md +++ b/doc/development/dangerbot.md @@ -119,13 +119,12 @@ However, you can speed these cycles up somewhat by emptying the to revert the change before merging! To enable the Dangerfile on another existing GitLab project, run the following -extra steps, based on [this procedure](https://danger.systems/guides/getting_started.html#creating-a-bot-account-for-danger-to-use): +extra steps: -1. Add `@gitlab-bot` to the project as a `reporter`. -1. Add the `@gitlab-bot`'s `GITLAB_API_PRIVATE_TOKEN` value as a value for a new CI/CD - variable named `DANGER_GITLAB_API_TOKEN`. +1. Create a [Project access tokens](../user/project/settings/project_access_tokens.md). +1. Add the token as a CI/CD project variable named `DANGER_GITLAB_API_TOKEN`. -You should add the `~Danger bot` label to the merge request before sending it +You should add the ~"Danger bot" label to the merge request before sending it for review. ## Current uses diff --git a/doc/user/admin_area/analytics/dev_ops_report.md b/doc/user/admin_area/analytics/dev_ops_report.md index 6ca5e5034bf..cb94bc8d35b 100644 --- a/doc/user/admin_area/analytics/dev_ops_report.md +++ b/doc/user/admin_area/analytics/dev_ops_report.md @@ -38,13 +38,14 @@ collected before this feature is available. ## DevOps Adoption **(ULTIMATE SELF)** -> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/247112) in GitLab 13.7 as a [Beta feature](https://about.gitlab.com/handbook/product/gitlab-the-product/#beta) +> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/247112) in GitLab 13.7 as a [Beta feature](https://about.gitlab.com/handbook/product/gitlab-the-product/#beta). +> - The Overview tab [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/330401) in GitLab 14.1. > - [Deployed behind a feature flag](../../../user/feature_flags.md), disabled by default. > - [Enabled by default](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/59267) in GitLab 14.0. > - Enabled on GitLab.com. > - For GitLab self-managed instances, GitLab administrators can opt to [disable it](#disable-or-enable-devops-adoption). **(ULTIMATE SELF)** -The DevOps Adoption tab shows you which groups within your organization are using the most essential features of GitLab: +DevOps Adoption shows you which groups within your organization are using the most essential features of GitLab: - Dev - Issues @@ -67,7 +68,7 @@ DevOps Adoption allows you to: - Identify specific groups that are lagging in their adoption of GitLab so you can help them along in their DevOps journey. - Find the groups that have adopted certain features and can provide guidance to other groups on how to use those features. -![DevOps Report](img/admin_devops_adoption_v14_0.png) +![DevOps Report](img/admin_devops_adoption_v14_1.png) ### Disable or enable DevOps Adoption diff --git a/doc/user/admin_area/analytics/img/admin_devops_adoption_v14_0.png b/doc/user/admin_area/analytics/img/admin_devops_adoption_v14_0.png Binary files differdeleted file mode 100644 index c3e51d349e4..00000000000 --- a/doc/user/admin_area/analytics/img/admin_devops_adoption_v14_0.png +++ /dev/null diff --git a/doc/user/admin_area/analytics/img/admin_devops_adoption_v14_1.png b/doc/user/admin_area/analytics/img/admin_devops_adoption_v14_1.png Binary files differnew file mode 100644 index 00000000000..79481e43e8e --- /dev/null +++ b/doc/user/admin_area/analytics/img/admin_devops_adoption_v14_1.png diff --git a/doc/user/group/devops_adoption/img/group_devops_adoption_v14_0.png b/doc/user/group/devops_adoption/img/group_devops_adoption_v14_0.png Binary files differdeleted file mode 100644 index fd73c8c5833..00000000000 --- a/doc/user/group/devops_adoption/img/group_devops_adoption_v14_0.png +++ /dev/null diff --git a/doc/user/group/devops_adoption/img/group_devops_adoption_v14_1.png b/doc/user/group/devops_adoption/img/group_devops_adoption_v14_1.png Binary files differnew file mode 100644 index 00000000000..a790a560a9b --- /dev/null +++ b/doc/user/group/devops_adoption/img/group_devops_adoption_v14_1.png diff --git a/doc/user/group/devops_adoption/index.md b/doc/user/group/devops_adoption/index.md index 0d39b4ea5d4..6056af1cb80 100644 --- a/doc/user/group/devops_adoption/index.md +++ b/doc/user/group/devops_adoption/index.md @@ -8,6 +8,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w > - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/321083) in GitLab 13.11 as a [Beta feature](https://about.gitlab.com/handbook/product/gitlab-the-product/#beta). > - [Feature flag removed](https://gitlab.com/gitlab-org/gitlab/-/issues/333556) in GitLab 14.1. +> - The Overview tab [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/330401) in GitLab 14.1. Prerequisites: @@ -38,7 +39,7 @@ With DevOps Adoption you can: - Identify specific sub-groups that are lagging in their adoption of GitLab so you can help them along in their DevOps journey. - Find the sub-groups that have adopted certain features and can provide guidance to other sub-groups on how to use those features. -![DevOps Report](img/group_devops_adoption_v14_0.png) +![DevOps Report](img/group_devops_adoption_v14_1.png) ## Enable data processing diff --git a/lib/gitlab/github_import/importer/pull_request_merged_by_importer.rb b/lib/gitlab/github_import/importer/pull_request_merged_by_importer.rb index 8173fdd5e3e..640914acf4d 100644 --- a/lib/gitlab/github_import/importer/pull_request_merged_by_importer.rb +++ b/lib/gitlab/github_import/importer/pull_request_merged_by_importer.rb @@ -43,7 +43,7 @@ module Gitlab def missing_author_note s_("GitHubImporter|*Merged by: %{author} at %{timestamp}*") % { - author: pull_request.merged_by.login, + author: pull_request.merged_by&.login || 'ghost', timestamp: pull_request.merged_at } end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index f643a0e73ba..78bd3883442 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -11072,6 +11072,9 @@ msgstr "" msgid "DevOps adoption" msgstr "" +msgid "DevopsAdoption|%{adoptedCount}/%{featuresCount} %{title} features adopted" +msgstr "" + msgid "DevopsAdoption|Add Group" msgstr "" @@ -11174,6 +11177,9 @@ msgstr "" msgid "DevopsAdoption|Ops" msgstr "" +msgid "DevopsAdoption|Overall adoption" +msgstr "" + msgid "DevopsAdoption|Pipelines" msgstr "" @@ -11231,6 +11237,9 @@ msgstr "" msgid "DevopsReport|Moderate" msgstr "" +msgid "DevopsReport|Overview" +msgstr "" + msgid "DevopsReport|Score" msgstr "" @@ -38970,7 +38979,7 @@ msgstr "" msgid "mrWidget|The source branch has been deleted" msgstr "" -msgid "mrWidget|The source branch is %{commitsBehindLinkStart}%{commitsBehind}%{commitsBehindLinkEnd} the target branch" +msgid "mrWidget|The source branch is %{link} the target branch" msgstr "" msgid "mrWidget|The source branch is being deleted" diff --git a/package.json b/package.json index 13c2c49f872..a3b26bbe027 100644 --- a/package.json +++ b/package.json @@ -57,9 +57,9 @@ "@babel/preset-env": "^7.10.1", "@gitlab/at.js": "1.5.7", "@gitlab/favicon-overlay": "2.0.0", - "@gitlab/svgs": "1.201.0", + "@gitlab/svgs": "1.202.0", "@gitlab/tributejs": "1.0.0", - "@gitlab/ui": "30.0.1", + "@gitlab/ui": "30.2.0", "@gitlab/visual-review-tools": "1.6.1", "@rails/actioncable": "6.1.3-2", "@rails/ujs": "6.1.3-2", diff --git a/spec/frontend/diffs/store/actions_spec.js b/spec/frontend/diffs/store/actions_spec.js index f25099cdecc..c2e5d07bcfd 100644 --- a/spec/frontend/diffs/store/actions_spec.js +++ b/spec/frontend/diffs/store/actions_spec.js @@ -1019,10 +1019,12 @@ describe('DiffsStoreActions', () => { const endpointUpdateUser = 'user/prefs'; let putSpy; let mock; + let gon; beforeEach(() => { mock = new MockAdapter(axios); putSpy = jest.spyOn(axios, 'put'); + gon = window.gon; mock.onPut(endpointUpdateUser).reply(200, {}); jest.spyOn(eventHub, '$emit').mockImplementation(); @@ -1030,6 +1032,7 @@ describe('DiffsStoreActions', () => { afterEach(() => { mock.restore(); + window.gon = gon; }); it('commits SET_SHOW_WHITESPACE', (done) => { @@ -1043,7 +1046,9 @@ describe('DiffsStoreActions', () => { ); }); - it('saves to the database', async () => { + it('saves to the database when the user is logged in', async () => { + window.gon = { current_user_id: 12345 }; + await setShowWhitespace( { state: { endpointUpdateUser }, commit() {} }, { showWhitespace: true, updateDatabase: true }, @@ -1052,6 +1057,17 @@ describe('DiffsStoreActions', () => { expect(putSpy).toHaveBeenCalledWith(endpointUpdateUser, { show_whitespace_in_diffs: true }); }); + it('does not try to save to the API if the user is not logged in', async () => { + window.gon = {}; + + await setShowWhitespace( + { state: { endpointUpdateUser }, commit() {} }, + { showWhitespace: true, updateDatabase: true }, + ); + + expect(putSpy).not.toHaveBeenCalled(); + }); + it('emits eventHub event', async () => { await setShowWhitespace( { state: {}, commit() {} }, diff --git a/spec/frontend/projects/commit/components/branches_dropdown_spec.js b/spec/frontend/projects/commit/components/branches_dropdown_spec.js index ab84c3768d0..30556cdeae1 100644 --- a/spec/frontend/projects/commit/components/branches_dropdown_spec.js +++ b/spec/frontend/projects/commit/components/branches_dropdown_spec.js @@ -3,6 +3,7 @@ import { shallowMount } from '@vue/test-utils'; import Vue from 'vue'; import Vuex from 'vuex'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; +import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; import BranchesDropdown from '~/projects/commit/components/branches_dropdown.vue'; Vue.use(Vuex); @@ -82,7 +83,7 @@ describe('BranchesDropdown', () => { expect(findSearchBoxByType().exists()).toBe(true); expect(findSearchBoxByType().vm.$attrs).toMatchObject({ placeholder: 'Search branches', - debounce: 250, + debounce: DEFAULT_DEBOUNCE_AND_THROTTLE_MS, }); }); }); diff --git a/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js b/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js index 115f21d8b35..f44f0b98207 100644 --- a/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js +++ b/spec/frontend/vue_mr_widget/components/mr_widget_header_spec.js @@ -1,4 +1,4 @@ -import { shallowMount } from '@vue/test-utils'; +import { shallowMount, mount } from '@vue/test-utils'; import { nextTick } from 'vue'; import Header from '~/vue_merge_request_widget/components/mr_widget_header.vue'; @@ -26,6 +26,15 @@ describe('MRWidgetHeader', () => { expect(downloadPlainDiffEl.attributes('href')).toBe('/mr/plainDiffPath'); }; + const commonMrProps = { + divergedCommitsCount: 1, + sourceBranch: 'mr-widget-refactor', + sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">Link</a>', + targetBranch: 'main', + targetBranchPath: '/foo/bar/main', + statusPath: 'abc', + }; + describe('computed', () => { describe('shouldShowCommitsBehindText', () => { it('return true when there are divergedCommitsCount', () => { @@ -59,36 +68,28 @@ describe('MRWidgetHeader', () => { describe('commitsBehindText', () => { it('returns singular when there is one commit', () => { - createComponent({ - mr: { - divergedCommitsCount: 1, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">Link</a>', - targetBranch: 'main', - targetBranchPath: '/foo/bar/main', - statusPath: 'abc', + wrapper = mount(Header, { + propsData: { + mr: commonMrProps, }, }); - expect(wrapper.vm.commitsBehindText).toBe( - 'The source branch is <a href="/foo/bar/main">1 commit behind</a> the target branch', + expect(wrapper.find('.diverged-commits-count').element.innerHTML).toBe( + 'The source branch is <a href="/foo/bar/main" class="gl-link">1 commit behind</a> the target branch', ); }); it('returns plural when there is more than one commit', () => { - createComponent({ - mr: { - divergedCommitsCount: 2, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">Link</a>', - targetBranch: 'main', - targetBranchPath: '/foo/bar/main', - statusPath: 'abc', + wrapper = mount(Header, { + propsData: { + mr: { + ...commonMrProps, + divergedCommitsCount: 2, + }, }, }); - - expect(wrapper.vm.commitsBehindText).toBe( - 'The source branch is <a href="/foo/bar/main">2 commits behind</a> the target branch', + expect(wrapper.find('.diverged-commits-count').element.innerHTML).toBe( + 'The source branch is <a href="/foo/bar/main" class="gl-link">2 commits behind</a> the target branch', ); }); }); @@ -273,19 +274,18 @@ describe('MRWidgetHeader', () => { describe('with diverged commits', () => { beforeEach(() => { - createComponent({ - mr: { - divergedCommitsCount: 12, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>', - sourceBranchRemoved: false, - targetBranchPath: 'foo/bar/commits-path', - targetBranchTreePath: 'foo/bar/tree/path', - targetBranch: 'main', - isOpen: true, - emailPatchesPath: '/mr/email-patches', - plainDiffPath: '/mr/plainDiffPath', - statusPath: 'abc', + wrapper = mount(Header, { + propsData: { + mr: { + ...commonMrProps, + divergedCommitsCount: 12, + sourceBranchRemoved: false, + targetBranchPath: 'foo/bar/commits-path', + targetBranchTreePath: 'foo/bar/tree/path', + isOpen: true, + emailPatchesPath: '/mr/email-patches', + plainDiffPath: '/mr/plainDiffPath', + }, }, }); }); diff --git a/spec/lib/gitlab/git_access_snippet_spec.rb b/spec/lib/gitlab/git_access_snippet_spec.rb index 2a672d523a0..3b85e3ddd1d 100644 --- a/spec/lib/gitlab/git_access_snippet_spec.rb +++ b/spec/lib/gitlab/git_access_snippet_spec.rb @@ -140,8 +140,6 @@ RSpec.describe Gitlab::GitAccessSnippet do end context 'when project is public but snippet feature is private' do - let(:project) { create(:project, :public) } - before do update_feature_access_level(project, :private) end @@ -151,7 +149,7 @@ RSpec.describe Gitlab::GitAccessSnippet do end context 'when project is not accessible' do - let(:project) { create(:project, :private) } + let_it_be(:project) { create(:project, :private) } [:anonymous, :non_member].each do |membership| context membership.to_s do @@ -168,7 +166,7 @@ RSpec.describe Gitlab::GitAccessSnippet do end context 'when project is archived' do - let(:project) { create(:project, :public, :archived) } + let_it_be(:project) { create(:project, :public, :archived) } [:anonymous, :non_member].each do |membership| context membership.to_s do @@ -214,7 +212,7 @@ RSpec.describe Gitlab::GitAccessSnippet do end context 'when snippet feature is disabled' do - let(:project) { create(:project, :public, :snippets_disabled) } + let_it_be(:project) { create(:project, :public, :snippets_disabled) } [:anonymous, :non_member, :author, :admin].each do |membership| context membership.to_s do @@ -306,9 +304,9 @@ RSpec.describe Gitlab::GitAccessSnippet do end describe 'repository size restrictions' do - let(:snippet) { create(:personal_snippet, :public, :repository) } - let(:actor) { snippet.author } + let_it_be(:snippet) { create(:personal_snippet, :public, :repository) } + let(:actor) { snippet.author } let(:oldrev) { TestEnv::BRANCH_SHA["snippet/single-file"] } let(:newrev) { TestEnv::BRANCH_SHA["snippet/edit-file"] } let(:ref) { "refs/heads/snippet/edit-file" } diff --git a/spec/lib/gitlab/github_import/importer/pull_request_merged_by_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_request_merged_by_importer_spec.rb index 01d9edf0ba1..016f6e5377b 100644 --- a/spec/lib/gitlab/github_import/importer/pull_request_merged_by_importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer/pull_request_merged_by_importer_spec.rb @@ -8,13 +8,14 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestMergedByImporter, :cle let(:project) { merge_request.project } let(:merged_at) { Time.new(2017, 1, 1, 12, 00).utc } let(:client_double) { double(user: double(id: 999, login: 'merger', email: 'merger@email.com')) } + let(:merger_user) { double(id: 999, login: 'merger') } let(:pull_request) do instance_double( Gitlab::GithubImport::Representation::PullRequest, iid: merge_request.iid, merged_at: merged_at, - merged_by: double(id: 999, login: 'merger') + merged_by: merger_user ) end @@ -48,4 +49,23 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestMergedByImporter, :cle expect(last_note.author).to eq(project.creator) end end + + context 'when the merger user is not provided' do + let(:merger_user) { nil } + + it 'adds a note referencing the merger user' do + expect { subject.execute } + .to change(Note, :count).by(1) + .and not_change(merge_request, :updated_at) + + metrics = merge_request.metrics.reload + expect(metrics.merged_by).to be_nil + expect(metrics.merged_at).to eq(merged_at) + + last_note = merge_request.notes.last + expect(last_note.note).to eq("*Merged by: ghost at 2017-01-01 12:00:00 UTC*") + expect(last_note.created_at).to eq(merged_at) + expect(last_note.author).to eq(project.creator) + end + end end diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index a2137ec6ed5..4b5fc57571b 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -1188,14 +1188,14 @@ RSpec.describe API::MergeRequests do expect(json_response['target_project_id']).to eq(merge_request.target_project.id) expect(json_response['draft']).to be false expect(json_response['work_in_progress']).to be false - expect(json_response['merge_when_pipeline_succeeds']).to be_falsy + expect(json_response['merge_when_pipeline_succeeds']).to be false expect(json_response['merge_status']).to eq('can_be_merged') expect(json_response['changes_count']).to eq(merge_request.merge_request_diff.real_size) expect(json_response['merge_error']).to eq(merge_request.merge_error) expect(json_response['user']['can_merge']).to be_truthy expect(json_response).not_to include('rebase_in_progress') - expect(json_response['first_contribution']).to be_falsy - expect(json_response['has_conflicts']).to be_falsy + expect(json_response['first_contribution']).to be false + expect(json_response['has_conflicts']).to be false expect(json_response['blocking_discussions_resolved']).to be_truthy expect(json_response['references']['short']).to eq("!#{merge_request.iid}") expect(json_response['references']['relative']).to eq("!#{merge_request.iid}") @@ -1394,7 +1394,7 @@ RSpec.describe API::MergeRequests do get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user2) - expect(json_response['user']['can_merge']).to be_falsy + expect(json_response['user']['can_merge']).to be false end it 'returns `checking` as its merge_status instead of `cannot_be_merged_rechecking`' do @@ -2663,7 +2663,7 @@ RSpec.describe API::MergeRequests do ) expect(response).to have_gitlab_http_status(:ok) - expect(source_repository.branch_exists?(source_branch)).to be_falsy + expect(source_repository.branch_exists?(source_branch)).to be false end end @@ -2681,7 +2681,7 @@ RSpec.describe API::MergeRequests do ) expect(response).to have_gitlab_http_status(:ok) - expect(source_repository.branch_exists?(source_branch)).to be_falsy + expect(source_repository.branch_exists?(source_branch)).to be false end it 'does not remove the source branch' do @@ -2803,7 +2803,7 @@ RSpec.describe API::MergeRequests do it 'sets to true' do merge_request.update!(merge_params: { 'force_remove_source_branch' => false } ) - expect(merge_request.force_remove_source_branch?).to be_falsey + expect(merge_request.force_remove_source_branch?).to be false put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { state_event: "close", remove_source_branch: true } diff --git a/yarn.lock b/yarn.lock index eb702d49077..b747fac3566 100644 --- a/yarn.lock +++ b/yarn.lock @@ -898,20 +898,20 @@ stylelint-declaration-strict-value "1.7.7" stylelint-scss "3.18.0" -"@gitlab/svgs@1.201.0": - version "1.201.0" - resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.201.0.tgz#5b390ae497331ae18e3a913cc5557b03c1d91ca9" - integrity sha512-Tv5lAfgiWgSBepZ0bak+kPq7q1uhtNRkD3Ih9LAAPY70XWDKej3Yv3L5joGEn/Xny2vt8Z+EHXqGE/BRblsEQw== +"@gitlab/svgs@1.202.0": + version "1.202.0" + resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.202.0.tgz#dbfad291fc5f597f0d31ca6a694fa8e78af57847" + integrity sha512-gnTSeb0o5UuUaDdjg1uzvVgETnXNyu0ta7arAHWOmLjDfXINwF6COR+ItM3ZVD//qUFSwYaCozgrDR642QAL4Q== "@gitlab/tributejs@1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@gitlab/tributejs/-/tributejs-1.0.0.tgz#672befa222aeffc83e7d799b0500a7a4418e59b8" integrity sha512-nmKw1+hB6MHvlmPz63yPwVs1qQkycHwsKgxpEbzmky16Y6mL4EJMk3w1b8QlOAF/AIAzjCERPhe/R4MJiohbZw== -"@gitlab/ui@30.0.1": - version "30.0.1" - resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-30.0.1.tgz#34743506758b03c19d1f98e07e7e644313c701cf" - integrity sha512-sfq+cqHGq7QM3QVtH6yk5/vGMqYBAyaRWRDdCfOiggjXQJPxS49hkXUjVbVDOTQIysmSA9M29sjY3ZMa8hdyTg== +"@gitlab/ui@30.2.0": + version "30.2.0" + resolved "https://registry.yarnpkg.com/@gitlab/ui/-/ui-30.2.0.tgz#eceec947f901cca9507a1ac8b3bd0031a5dcacf9" + integrity sha512-rYG3HyUHZQyum9+6OKvp45r9b9E/wzAl8rpFyIIZMg6a14JPfsGhdjXqycWlLxf3TAsbTD6MtjQm/z/I8J6V8g== dependencies: "@babel/standalone" "^7.0.0" bootstrap-vue "2.18.1" |