Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-20 21:08:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-20 21:08:51 +0300
commitdf2eda3f14dccb703bd7054d4ddde7803cb1fe7e (patch)
tree0200bb0def01cde22da3bc4c9ed0a7b0f91d6b50
parentb9bac6dbf78a5a7976fba14aaeef96bdeb0da612 (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--.gitlab/ci/docs.gitlab-ci.yml4
-rw-r--r--.gitlab/ci/memory.gitlab-ci.yml10
-rw-r--r--.gitlab/ci/qa.gitlab-ci.yml4
-rw-r--r--.gitlab/ci/reports.gitlab-ci.yml12
-rw-r--r--.gitlab/ci/review.gitlab-ci.yml4
-rw-r--r--.gitlab/ci/setup.gitlab-ci.yml4
-rw-r--r--.gitlab/ci/yaml.gitlab-ci.yml3
-rw-r--r--app/assets/javascripts/diffs/components/diff_expansion_cell.vue24
-rw-r--r--app/assets/javascripts/diffs/store/mutations.js1
-rw-r--r--app/assets/javascripts/diffs/store/utils.js64
-rw-r--r--app/assets/javascripts/locale/sprintf.js4
-rw-r--r--app/models/ci/build.rb6
-rw-r--r--app/models/ci/pipeline.rb4
-rw-r--r--app/models/concerns/with_uploads.rb1
-rw-r--r--app/models/merge_request.rb11
-rw-r--r--changelogs/unreleased/7003-fail-to-start-server-without-ar-connection.yml5
-rw-r--r--changelogs/unreleased/public-api-for-merge-trains.yml5
-rw-r--r--changelogs/unreleased/remove-duplicate-auth-refresh-on-project-create.yml5
-rw-r--r--config/initializers/active_record_lifecycle.rb2
-rw-r--r--db/migrate/20200213155311_add_npm_package_requests_forwarding_to_application_settings.rb20
-rw-r--r--db/schema.rb1
-rw-r--r--doc/administration/audit_events.md58
-rw-r--r--doc/administration/logs.md224
-rw-r--r--doc/administration/monitoring/prometheus/index.md38
-rw-r--r--doc/api/merge_trains.md80
-rw-r--r--doc/development/adding_database_indexes.md2
-rw-r--r--doc/development/migration_style_guide.md19
-rw-r--r--doc/user/project/clusters/kubernetes_pod_logs.md10
-rw-r--r--lib/api/helpers.rb4
-rw-r--r--locale/gitlab.pot6
-rw-r--r--spec/features/merge_request/user_views_diffs_spec.rb27
-rw-r--r--spec/fixtures/api/schemas/public_api/v4/merge_request_simple.json26
-rw-r--r--spec/javascripts/diffs/components/diff_expansion_cell_spec.js203
-rw-r--r--spec/javascripts/diffs/store/mutations_spec.js3
-rw-r--r--spec/javascripts/diffs/store/utils_spec.js124
-rw-r--r--spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb3
-rw-r--r--spec/lib/banzai/pipeline/gfm_pipeline_spec.rb2
-rw-r--r--spec/lib/event_filter_spec.rb21
-rw-r--r--spec/lib/gitlab/auth_spec.rb3
-rw-r--r--spec/lib/gitlab/checks/force_push_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/build/policy/changes_spec.rb5
-rw-r--r--spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/build/policy/variables_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/config/external/file/local_spec.rb6
-rw-r--r--spec/lib/gitlab/ci/config/external/file/project_spec.rb7
-rw-r--r--spec/lib/gitlab/ci/config/external/file/template_spec.rb6
-rw-r--r--spec/lib/gitlab/ci/config/external/mapper_spec.rb5
-rw-r--r--spec/lib/gitlab/ci/config/external/processor_spec.rb7
-rw-r--r--spec/lib/gitlab/ci/config_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/build_spec.rb4
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/command_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/create_spec.rb4
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb4
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb5
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb6
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb4
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb5
-rw-r--r--spec/lib/gitlab/ci/status/composite_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/trace/chunked_io_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/trace/stream_spec.rb2
-rw-r--r--spec/lib/gitlab/data_builder/wiki_page_spec.rb2
-rw-r--r--spec/lib/gitlab/git/lfs_changes_spec.rb2
-rw-r--r--spec/lib/gitlab/git/merge_base_spec.rb2
-rw-r--r--spec/lib/gitlab/git/push_spec.rb3
-rw-r--r--spec/lib/gitlab/git_post_receive_spec.rb2
-rw-r--r--spec/lib/gitlab/gitaly_client/operation_service_spec.rb4
-rw-r--r--spec/lib/gitlab/global_id_spec.rb2
-rw-r--r--spec/lib/gitlab/graphql/loaders/batch_lfs_oid_loader_spec.rb2
-rw-r--r--spec/lib/gitlab/hashed_storage/migrator_spec.rb4
-rw-r--r--spec/lib/gitlab/hook_data/issuable_builder_spec.rb2
-rw-r--r--spec/lib/gitlab/hook_data/issue_builder_spec.rb4
-rw-r--r--spec/lib/gitlab/hook_data/merge_request_builder_spec.rb2
-rw-r--r--spec/lib/gitlab/import/merge_request_helpers_spec.rb4
-rw-r--r--spec/lib/gitlab/import_export/repo_saver_spec.rb2
-rw-r--r--spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb4
-rw-r--r--spec/lib/gitlab/json_cache_spec.rb3
-rw-r--r--spec/lib/gitlab/language_detection_spec.rb6
-rw-r--r--spec/lib/gitlab/metrics/dashboard/finder_spec.rb6
-rw-r--r--spec/lib/gitlab/phabricator_import/cache/map_spec.rb2
-rw-r--r--spec/lib/gitlab/phabricator_import/issues/task_importer_spec.rb2
-rw-r--r--spec/lib/gitlab/project_template_spec.rb2
-rw-r--r--spec/lib/gitlab/repo_path_spec.rb2
-rw-r--r--spec/lib/gitlab/sanitizers/exif_spec.rb6
-rw-r--r--spec/lib/gitlab/shell_spec.rb3
-rw-r--r--spec/lib/gitlab/slash_commands/issue_move_spec.rb10
-rw-r--r--spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb10
-rw-r--r--spec/lib/gitlab/template/finders/repo_template_finders_spec.rb3
-rw-r--r--spec/lib/gitlab/workhorse_spec.rb2
-rw-r--r--spec/support/capybara.rb3
89 files changed, 896 insertions, 336 deletions
diff --git a/.gitlab/ci/docs.gitlab-ci.yml b/.gitlab/ci/docs.gitlab-ci.yml
index 3e5ffcf796a..c6f758b6719 100644
--- a/.gitlab/ci/docs.gitlab-ci.yml
+++ b/.gitlab/ci/docs.gitlab-ci.yml
@@ -46,9 +46,7 @@ docs lint:
- .docs:rules:docs-lint
image: "registry.gitlab.com/gitlab-org/gitlab-docs:docs-lint"
stage: test
- needs:
- - job: "retrieve-tests-metadata"
- artifacts: false
+ needs: []
script:
- scripts/lint-doc.sh
# Lint Markdown
diff --git a/.gitlab/ci/memory.gitlab-ci.yml b/.gitlab/ci/memory.gitlab-ci.yml
index a8e2d90a4ee..b090cef7796 100644
--- a/.gitlab/ci/memory.gitlab-ci.yml
+++ b/.gitlab/ci/memory.gitlab-ci.yml
@@ -8,6 +8,10 @@
memory-static:
extends: .only-code-memory-job-base
+ stage: test
+ needs:
+ - job: setup-test-env
+ artifacts: true
variables:
SETUP_DB: "false"
script:
@@ -36,6 +40,12 @@ memory-on-boot:
extends:
- .only-code-memory-job-base
- .use-pg10
+ stage: test
+ needs:
+ - job: setup-test-env
+ artifacts: true
+ - job: compile-assets pull-cache
+ artifacts: true
variables:
NODE_ENV: "production"
RAILS_ENV: "production"
diff --git a/.gitlab/ci/qa.gitlab-ci.yml b/.gitlab/ci/qa.gitlab-ci.yml
index 180c62445df..c25f30f39a8 100644
--- a/.gitlab/ci/qa.gitlab-ci.yml
+++ b/.gitlab/ci/qa.gitlab-ci.yml
@@ -3,9 +3,7 @@
- .default-tags
- .default-retry
stage: test
- needs:
- - job: "retrieve-tests-metadata"
- artifacts: false
+ needs: []
cache:
key: "qa-framework-jobs:v1"
paths:
diff --git a/.gitlab/ci/reports.gitlab-ci.yml b/.gitlab/ci/reports.gitlab-ci.yml
index 9bd8109edc5..964aa8e523f 100644
--- a/.gitlab/ci/reports.gitlab-ci.yml
+++ b/.gitlab/ci/reports.gitlab-ci.yml
@@ -12,9 +12,7 @@ code_quality:
- .default-retry
- .reports:rules:code_quality
stage: test
- needs:
- - job: "retrieve-tests-metadata"
- artifacts: false
+ needs: []
image: docker:stable
allow_failure: true
services:
@@ -54,9 +52,7 @@ sast:
- .reports:rules:sast
stage: test
allow_failure: true
- needs:
- - job: "retrieve-tests-metadata"
- artifacts: false
+ needs: []
artifacts:
paths:
- gl-sast-report.json # GitLab-specific
@@ -94,9 +90,7 @@ dependency_scanning:
- .default-retry
- .reports:rules:dependency_scanning
stage: test
- needs:
- - job: "retrieve-tests-metadata"
- artifacts: false
+ needs: []
image: docker:stable
variables:
DOCKER_DRIVER: overlay2
diff --git a/.gitlab/ci/review.gitlab-ci.yml b/.gitlab/ci/review.gitlab-ci.yml
index 77d0ebaccfc..3835ad62ba2 100644
--- a/.gitlab/ci/review.gitlab-ci.yml
+++ b/.gitlab/ci/review.gitlab-ci.yml
@@ -248,9 +248,7 @@ danger-review:
- .review:rules:danger
image: registry.gitlab.com/gitlab-org/gitlab-build-images:danger
stage: test
- needs:
- - job: "retrieve-tests-metadata"
- artifacts: false
+ needs: []
script:
- git version
- node --version
diff --git a/.gitlab/ci/setup.gitlab-ci.yml b/.gitlab/ci/setup.gitlab-ci.yml
index fb203db1478..b4b911ab607 100644
--- a/.gitlab/ci/setup.gitlab-ci.yml
+++ b/.gitlab/ci/setup.gitlab-ci.yml
@@ -23,12 +23,13 @@ cache gems:
extends:
- .default-tags
- .default-retry
- dependencies: []
+ needs: []
gitlab_git_test:
extends:
- .minimal-job
- .setup:rules:gitlab_git_test
+ stage: test
script:
- spec/support/prepare-gitlab-git-test-for-commit --check-for-changes
@@ -36,5 +37,6 @@ no_ee_check:
extends:
- .minimal-job
- .setup:rules:no_ee_check
+ stage: test
script:
- scripts/no-ee-check
diff --git a/.gitlab/ci/yaml.gitlab-ci.yml b/.gitlab/ci/yaml.gitlab-ci.yml
index cdc3aa6e577..6c0286ed18a 100644
--- a/.gitlab/ci/yaml.gitlab-ci.yml
+++ b/.gitlab/ci/yaml.gitlab-ci.yml
@@ -6,7 +6,8 @@ lint-ci-gitlab:
- .default-retry
- .yaml:rules
image: sdesbure/yamllint:latest
- dependencies: []
+ stage: test
+ needs: []
variables:
LINT_PATHS: .gitlab-ci.yml .gitlab/ci lib/gitlab/ci/templates changelogs
script:
diff --git a/app/assets/javascripts/diffs/components/diff_expansion_cell.vue b/app/assets/javascripts/diffs/components/diff_expansion_cell.vue
index 23fbfc2b74b..4eae2e09c08 100644
--- a/app/assets/javascripts/diffs/components/diff_expansion_cell.vue
+++ b/app/assets/javascripts/diffs/components/diff_expansion_cell.vue
@@ -3,7 +3,7 @@ import { mapState, mapActions } from 'vuex';
import createFlash from '~/flash';
import { s__ } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue';
-import { UNFOLD_COUNT } from '../constants';
+import { UNFOLD_COUNT, INLINE_DIFF_VIEW_TYPE, PARALLEL_DIFF_VIEW_TYPE } from '../constants';
import * as utils from '../store/utils';
import tooltip from '../../vue_shared/directives/tooltip';
@@ -11,6 +11,16 @@ const EXPAND_ALL = 0;
const EXPAND_UP = 1;
const EXPAND_DOWN = 2;
+const lineNumberByViewType = (viewType, diffLine) => {
+ const numberGetters = {
+ [INLINE_DIFF_VIEW_TYPE]: line => line?.new_line,
+ [PARALLEL_DIFF_VIEW_TYPE]: line => (line?.right || line?.left)?.new_line,
+ };
+ const numberGetter = numberGetters[viewType];
+
+ return numberGetter && numberGetter(diffLine);
+};
+
export default {
directives: {
tooltip,
@@ -67,12 +77,16 @@ export default {
...mapActions('diffs', ['loadMoreLines']),
getPrevLineNumber(oldLineNumber, newLineNumber) {
const diffFile = utils.findDiffFile(this.diffFiles, this.fileHash);
- const indexForInline = utils.findIndexInInlineLines(diffFile.highlighted_diff_lines, {
+ const lines = {
+ [INLINE_DIFF_VIEW_TYPE]: diffFile.highlighted_diff_lines,
+ [PARALLEL_DIFF_VIEW_TYPE]: diffFile.parallel_diff_lines,
+ };
+ const index = utils.getPreviousLineIndex(this.diffViewType, diffFile, {
oldLineNumber,
newLineNumber,
});
- const prevLine = diffFile.highlighted_diff_lines[indexForInline - 2];
- return (prevLine && prevLine.new_line) || 0;
+
+ return lineNumberByViewType(this.diffViewType, lines[this.diffViewType][index - 2]) || 0;
},
callLoadMoreLines(
endpoint,
@@ -114,7 +128,7 @@ export default {
this.handleExpandAllLines(expandOptions);
}
},
- handleExpandUpLines(expandOptions = EXPAND_ALL) {
+ handleExpandUpLines(expandOptions) {
const { endpoint, fileHash, view, oldLineNumber, newLineNumber, offset } = expandOptions;
const bottom = this.isBottom;
diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js
index c26411af5d7..086a7872a5d 100644
--- a/app/assets/javascripts/diffs/store/mutations.js
+++ b/app/assets/javascripts/diffs/store/mutations.js
@@ -140,6 +140,7 @@ export default {
addContextLines({
inlineLines: diffFile.highlighted_diff_lines,
parallelLines: diffFile.parallel_diff_lines,
+ diffViewType: state.diffViewType,
contextLines: lines,
bottom,
lineNumbers,
diff --git a/app/assets/javascripts/diffs/store/utils.js b/app/assets/javascripts/diffs/store/utils.js
index 80972d2aeb8..29133c814ea 100644
--- a/app/assets/javascripts/diffs/store/utils.js
+++ b/app/assets/javascripts/diffs/store/utils.js
@@ -13,6 +13,8 @@ import {
LINES_TO_BE_RENDERED_DIRECTLY,
MAX_LINES_TO_BE_RENDERED,
TREE_TYPE,
+ INLINE_DIFF_VIEW_TYPE,
+ PARALLEL_DIFF_VIEW_TYPE,
} from '../constants';
export function findDiffFile(files, match, matchKey = 'file_hash') {
@@ -93,8 +95,7 @@ export function getNoteFormData(params) {
export const findIndexInInlineLines = (lines, lineNumbers) => {
const { oldLineNumber, newLineNumber } = lineNumbers;
- return _.findIndex(
- lines,
+ return lines.findIndex(
line => line.old_line === oldLineNumber && line.new_line === newLineNumber,
);
};
@@ -102,8 +103,7 @@ export const findIndexInInlineLines = (lines, lineNumbers) => {
export const findIndexInParallelLines = (lines, lineNumbers) => {
const { oldLineNumber, newLineNumber } = lineNumbers;
- return _.findIndex(
- lines,
+ return lines.findIndex(
line =>
line.left &&
line.right &&
@@ -112,13 +112,32 @@ export const findIndexInParallelLines = (lines, lineNumbers) => {
);
};
+const indexGettersByViewType = {
+ [INLINE_DIFF_VIEW_TYPE]: findIndexInInlineLines,
+ [PARALLEL_DIFF_VIEW_TYPE]: findIndexInParallelLines,
+};
+
+export const getPreviousLineIndex = (diffViewType, file, lineNumbers) => {
+ const findIndex = indexGettersByViewType[diffViewType];
+ const lines = {
+ [INLINE_DIFF_VIEW_TYPE]: file.highlighted_diff_lines,
+ [PARALLEL_DIFF_VIEW_TYPE]: file.parallel_diff_lines,
+ };
+
+ return findIndex && findIndex(lines[diffViewType], lineNumbers);
+};
+
export function removeMatchLine(diffFile, lineNumbers, bottom) {
const indexForInline = findIndexInInlineLines(diffFile.highlighted_diff_lines, lineNumbers);
const indexForParallel = findIndexInParallelLines(diffFile.parallel_diff_lines, lineNumbers);
const factor = bottom ? 1 : -1;
- diffFile.highlighted_diff_lines.splice(indexForInline + factor, 1);
- diffFile.parallel_diff_lines.splice(indexForParallel + factor, 1);
+ if (indexForInline > -1) {
+ diffFile.highlighted_diff_lines.splice(indexForInline + factor, 1);
+ }
+ if (indexForParallel > -1) {
+ diffFile.parallel_diff_lines.splice(indexForParallel + factor, 1);
+ }
}
export function addLineReferences(lines, lineNumbers, bottom, isExpandDown, nextLineNumbers) {
@@ -160,8 +179,8 @@ export function addLineReferences(lines, lineNumbers, bottom, isExpandDown, next
return linesWithNumbers;
}
-export function addContextLines(options) {
- const { inlineLines, parallelLines, contextLines, lineNumbers, isExpandDown } = options;
+function addParallelContextLines(options) {
+ const { parallelLines, contextLines, lineNumbers, isExpandDown } = options;
const normalizedParallelLines = contextLines.map(line => ({
left: line,
right: line,
@@ -170,17 +189,40 @@ export function addContextLines(options) {
const factor = isExpandDown ? 1 : 0;
if (!isExpandDown && options.bottom) {
- inlineLines.push(...contextLines);
parallelLines.push(...normalizedParallelLines);
} else {
- const inlineIndex = findIndexInInlineLines(inlineLines, lineNumbers);
const parallelIndex = findIndexInParallelLines(parallelLines, lineNumbers);
- inlineLines.splice(inlineIndex + factor, 0, ...contextLines);
parallelLines.splice(parallelIndex + factor, 0, ...normalizedParallelLines);
}
}
+function addInlineContextLines(options) {
+ const { inlineLines, contextLines, lineNumbers, isExpandDown } = options;
+ const factor = isExpandDown ? 1 : 0;
+
+ if (!isExpandDown && options.bottom) {
+ inlineLines.push(...contextLines);
+ } else {
+ const inlineIndex = findIndexInInlineLines(inlineLines, lineNumbers);
+
+ inlineLines.splice(inlineIndex + factor, 0, ...contextLines);
+ }
+}
+
+export function addContextLines(options) {
+ const { diffViewType } = options;
+ const contextLineHandlers = {
+ [INLINE_DIFF_VIEW_TYPE]: addInlineContextLines,
+ [PARALLEL_DIFF_VIEW_TYPE]: addParallelContextLines,
+ };
+ const contextLineHandler = contextLineHandlers[diffViewType];
+
+ if (contextLineHandler) {
+ contextLineHandler(options);
+ }
+}
+
/**
* Trims the first char of the `richText` property when it's either a space or a diff symbol.
* @param {Object} line
diff --git a/app/assets/javascripts/locale/sprintf.js b/app/assets/javascripts/locale/sprintf.js
index a3557fbf3fb..7ab4e725d99 100644
--- a/app/assets/javascripts/locale/sprintf.js
+++ b/app/assets/javascripts/locale/sprintf.js
@@ -1,4 +1,4 @@
-import _ from 'underscore';
+import { escape } from 'lodash';
/**
Very limited implementation of sprintf supporting only named parameters.
@@ -17,7 +17,7 @@ export default (input, parameters, escapeParameters = true) => {
if (parameters) {
Object.keys(parameters).forEach(parameterName => {
const parameterValue = parameters[parameterName];
- const escapedParameterValue = escapeParameters ? _.escape(parameterValue) : parameterValue;
+ const escapedParameterValue = escapeParameters ? escape(parameterValue) : parameterValue;
output = output.replace(new RegExp(`%{${parameterName}}`, 'g'), escapedParameterValue);
});
}
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index e95e2c538c5..d61f0bbfb10 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -173,8 +173,10 @@ module Ci
scope :queued_before, ->(time) { where(arel_table[:queued_at].lt(time)) }
scope :order_id_desc, -> { order('ci_builds.id DESC') }
- PROJECT_ROUTE_AND_NAMESPACE_ROUTE = { project: [:project_feature, :route, { namespace: :route }] }.freeze
- scope :preload_project_and_pipeline_project, -> { preload(PROJECT_ROUTE_AND_NAMESPACE_ROUTE, pipeline: PROJECT_ROUTE_AND_NAMESPACE_ROUTE) }
+ scope :preload_project_and_pipeline_project, -> do
+ preload(Ci::Pipeline::PROJECT_ROUTE_AND_NAMESPACE_ROUTE,
+ pipeline: Ci::Pipeline::PROJECT_ROUTE_AND_NAMESPACE_ROUTE)
+ end
acts_as_taggable
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 3209e077a08..4ae64b6c8f1 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -16,6 +16,10 @@ module Ci
include FromUnion
include UpdatedAtFilterable
+ PROJECT_ROUTE_AND_NAMESPACE_ROUTE = {
+ project: [:project_feature, :route, { namespace: :route }]
+ }.freeze
+
BridgeStatusError = Class.new(StandardError)
sha_attribute :source_sha
diff --git a/app/models/concerns/with_uploads.rb b/app/models/concerns/with_uploads.rb
index 6c6febd186c..d90f32d8b1c 100644
--- a/app/models/concerns/with_uploads.rb
+++ b/app/models/concerns/with_uploads.rb
@@ -18,7 +18,6 @@
module WithUploads
extend ActiveSupport::Concern
include FastDestroyAll::Helpers
- include FeatureGate
# Currently there is no simple way how to select only not-mounted
# uploads, it should be all FileUploaders so we select them by
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 5dda1bd8cc7..0bc4e550678 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -235,12 +235,17 @@ class MergeRequest < ApplicationRecord
end
scope :join_project, -> { joins(:target_project) }
scope :references_project, -> { references(:target_project) }
+
+ PROJECT_ROUTE_AND_NAMESPACE_ROUTE = [
+ target_project: [:route, { namespace: :route }],
+ source_project: [:route, { namespace: :route }]
+ ].freeze
+
scope :with_api_entity_associations, -> {
preload(:assignees, :author, :unresolved_notes, :labels, :milestone,
:timelogs, :latest_merge_request_diff,
- metrics: [:latest_closed_by, :merged_by],
- target_project: [:route, { namespace: :route }],
- source_project: [:route, { namespace: :route }])
+ *PROJECT_ROUTE_AND_NAMESPACE_ROUTE,
+ metrics: [:latest_closed_by, :merged_by])
}
scope :by_target_branch_wildcard, ->(wildcard_branch_name) do
where("target_branch LIKE ?", ApplicationRecord.sanitize_sql_like(wildcard_branch_name).tr('*', '%'))
diff --git a/changelogs/unreleased/7003-fail-to-start-server-without-ar-connection.yml b/changelogs/unreleased/7003-fail-to-start-server-without-ar-connection.yml
new file mode 100644
index 00000000000..806e1ccc362
--- /dev/null
+++ b/changelogs/unreleased/7003-fail-to-start-server-without-ar-connection.yml
@@ -0,0 +1,5 @@
+---
+title: Refuse to start web server without a working ActiveRecord connection
+merge_request: 25160
+author:
+type: other
diff --git a/changelogs/unreleased/public-api-for-merge-trains.yml b/changelogs/unreleased/public-api-for-merge-trains.yml
new file mode 100644
index 00000000000..97da15794e8
--- /dev/null
+++ b/changelogs/unreleased/public-api-for-merge-trains.yml
@@ -0,0 +1,5 @@
+---
+title: Allow users to get Merge Trains entries via Public API
+merge_request: 25229
+author:
+type: added
diff --git a/changelogs/unreleased/remove-duplicate-auth-refresh-on-project-create.yml b/changelogs/unreleased/remove-duplicate-auth-refresh-on-project-create.yml
new file mode 100644
index 00000000000..db0fe9e34e6
--- /dev/null
+++ b/changelogs/unreleased/remove-duplicate-auth-refresh-on-project-create.yml
@@ -0,0 +1,5 @@
+---
+title: Remove duplicate authorization refresh for group members on project creation
+merge_request:
+author:
+type: performance
diff --git a/config/initializers/active_record_lifecycle.rb b/config/initializers/active_record_lifecycle.rb
index 2cf0f0439a9..493d328b93e 100644
--- a/config/initializers/active_record_lifecycle.rb
+++ b/config/initializers/active_record_lifecycle.rb
@@ -14,6 +14,8 @@ end
if defined?(ActiveRecord::Base)
Gitlab::Cluster::LifecycleEvents.on_before_fork do
+ raise 'ActiveRecord connection not established. Unable to start.' unless Gitlab::Database.exists?
+
# the following is highly recommended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
ActiveRecord::Base.connection.disconnect!
diff --git a/db/migrate/20200213155311_add_npm_package_requests_forwarding_to_application_settings.rb b/db/migrate/20200213155311_add_npm_package_requests_forwarding_to_application_settings.rb
new file mode 100644
index 00000000000..db67437232c
--- /dev/null
+++ b/db/migrate/20200213155311_add_npm_package_requests_forwarding_to_application_settings.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddNpmPackageRequestsForwardingToApplicationSettings < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_column_with_default(:application_settings, :npm_package_requests_forwarding,
+ :boolean,
+ default: false,
+ allow_null: false)
+ end
+
+ def down
+ remove_column(:application_settings, :npm_package_requests_forwarding)
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 8d95e0b4700..9d3ba5f3645 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -351,6 +351,7 @@ ActiveRecord::Schema.define(version: 2020_02_14_034836) do
t.boolean "prevent_merge_requests_committers_approval", default: false, null: false
t.boolean "email_restrictions_enabled", default: false, null: false
t.text "email_restrictions"
+ t.boolean "npm_package_requests_forwarding", default: false, null: false
t.index ["custom_project_templates_group_id"], name: "index_application_settings_on_custom_project_templates_group_id"
t.index ["file_template_project_id"], name: "index_application_settings_on_file_template_project_id"
t.index ["instance_administration_project_id"], name: "index_applicationsettings_on_instance_administration_project_id"
diff --git a/doc/administration/audit_events.md b/doc/administration/audit_events.md
index cf017c0167b..2f4079396e6 100644
--- a/doc/administration/audit_events.md
+++ b/doc/administration/audit_events.md
@@ -3,28 +3,28 @@
GitLab offers a way to view the changes made within the GitLab server for owners and administrators on a [paid plan][ee].
GitLab system administrators can also take advantage of the logs located on the
-filesystem, see [the logs system documentation](logs.md) for more details.
+filesystem. See [the logs system documentation](logs.md) for more details.
## Overview
-**Audit Events** is a tool for GitLab owners and administrators to be
-able to track important events such as who performed certain actions and the
-time they happened. These actions could be, for example, change a user
+**Audit Events** is a tool for GitLab owners and administrators
+to track important events such as who performed certain actions and the
+time they happened. For example, these actions could be a change to a user
permission level, who added a new user, or who removed a user.
-## Use-cases
+## Use cases
-- Check who the person was that changed the permission level of a particular
- user for a project in GitLab.
-- Use it to track which users have access to a certain group of projects
- in GitLab, and who gave them that permission level.
+- Check who changed the permission level of a particular
+ user for a GitLab project.
+- Track which users have access to a certain group of projects
+ in GitLab, and who gave them that permission level.
## List of events
There are two kinds of events logged:
-- Events scoped to the group or project, used by group / project managers
- to look up who made what change.
+- Events scoped to the group or project, used by group and project managers
+ to look up who made a change.
- Instance events scoped to the whole GitLab instance, used by your Compliance team to
perform formal audits.
@@ -36,9 +36,9 @@ You need Owner [permissions] to view the group Audit Events page.
To view a group's audit events, navigate to **Group > Settings > Audit Events**.
From there, you can see the following actions:
-- Group name/path changed
+- Group name or path changed
- Group repository size limit changed
-- Group created/deleted
+- Group created or deleted
- Group changed visibility
- User was added to group and with which [permissions]
- Permissions changes of a user assigned to a group
@@ -48,11 +48,11 @@ From there, you can see the following actions:
- [Project shared with group](../user/project/members/share_project_with_groups.md)
and with which [permissions]
- Removal of a previously shared group with a project
-- LFS enabled/disabled
+- LFS enabled or disabled
- Shared runners minutes limit changed
-- Membership lock enabled/disabled
-- Request access enabled/disabled
-- 2FA enforcement/grace period changed
+- Membership lock enabled or disabled
+- Request access enabled or disabled
+- 2FA enforcement or grace period changed
- Roles allowed to create project changed
Group events can also be accessed via the [Group Audit Events API](../api/audit_events.md#group-audit-events-starter)
@@ -65,8 +65,8 @@ You need Maintainer [permissions] or higher to view the project Audit Events pag
To view a project's audit events, navigate to **Project > Settings > Audit Events**.
From there, you can see the following actions:
-- Added/removed deploy keys
-- Project created/deleted/renamed/moved(transferred)/changed path
+- Added or removed deploy keys
+- Project created, deleted, renamed, moved(transferred), changed path
- Project changed visibility level
- User was added to project and with which [permissions]
- Permission changes of a user assigned to a project
@@ -75,7 +75,7 @@ From there, you can see the following actions:
- Project repository was downloaded
- Project was archived
- Project was unarchived
-- Added/removed/updated protected branches
+- Added, removed, or updated protected branches
- Release was added to a project
- Release was updated
- Release milestone associations changed
@@ -94,20 +94,20 @@ In addition to the group and project events, the following user actions are also
recorded:
- Failed Logins
-- Sign-in events and the authentication type (standard, LDAP, OmniAuth, etc.)
+- Sign-in events and the authentication type (such as standard, LDAP, or OmniAuth)
- Added SSH key
-- Added/removed email
+- Added or removed email
- Changed password
- Ask for password reset
- Grant OAuth access
-- Started/stopped user impersonation
+- Started or stopped user impersonation
- Changed username ([introduced](https://gitlab.com/gitlab-org/gitlab/issues/7797) in GitLab 12.8)
- User was deleted ([introduced](https://gitlab.com/gitlab-org/gitlab/issues/251) in GitLab 12.8)
- User was added ([introduced](https://gitlab.com/gitlab-org/gitlab/issues/251) in GitLab 12.8)
- User was blocked via Admin Area ([introduced](https://gitlab.com/gitlab-org/gitlab/issues/251) in GitLab 12.8)
-It is possible to filter particular actions by choosing an audit data type from
-the filter dropdown box. You can further filter by specific group, project or user
+It's possible to filter particular actions by choosing an audit data type from
+the filter dropdown box. You can further filter by specific group, project, or user
(for authentication events).
![audit log](img/audit_log.png)
@@ -116,8 +116,8 @@ Instance events can also be accessed via the [Instance Audit Events API](../api/
### Missing events
-Some events are not being tracked in Audit Events. Please see the following
-epics for more detail on which events are not being tracked and our progress
+Some events are not tracked in Audit Events. See the following
+epics for more detail on which events are not being tracked, and our progress
on adding these events into GitLab:
- [Project settings and activity](https://gitlab.com/groups/gitlab-org/-/epics/474)
@@ -129,8 +129,8 @@ on adding these events into GitLab:
#### Repository push
The current architecture of audit events is not prepared to receive a very high amount of records.
-It may make your project/admin audit logs UI very busy and the disk space consumed by the
-`audit_events` Postgres table will increase considerably. Thus, it's disabled by default
+It may make the user interface for your project or audit logs very busy, and the disk space consumed by the
+`audit_events` Postgres table will increase considerably. It's disabled by default
to prevent performance degradations on GitLab instances with very high Git write traffic.
In an upcoming release, Audit Logs for Git push events will be enabled
diff --git a/doc/administration/logs.md b/doc/administration/logs.md
index b98f02ccc98..d224ba51bb3 100644
--- a/doc/administration/logs.md
+++ b/doc/administration/logs.md
@@ -1,10 +1,9 @@
# Log system
-GitLab has an advanced log system where everything is logged so that you
+GitLab has an advanced log system where everything is logged, so you
can analyze your instance using various system log files. In addition to
-system log files, GitLab Enterprise Edition comes with Audit Events.
-Find more about them [in Audit Events
-documentation](audit_events.md)
+system log files, GitLab Enterprise Edition provides Audit Events.
+Find more about them [in Audit Events documentation](audit_events.md).
System log files are typically plain text in a standard log file format.
This guide talks about how to read and use these system log files.
@@ -13,21 +12,40 @@ This guide talks about how to read and use these system log files.
This file lives in `/var/log/gitlab/gitlab-rails/production_json.log` for
Omnibus GitLab packages or in `/home/git/gitlab/log/production_json.log` for
-installations from source. (When GitLab is running in an environment
-other than production, the corresponding logfile is shown here.)
+installations from source. When GitLab is running in an environment
+other than production, the corresponding logfile is shown here.
It contains a structured log for Rails controller requests received from
GitLab, thanks to [Lograge](https://github.com/roidrage/lograge/). Note that
requests from the API are logged to a separate file in `api_json.log`.
-Each line contains a JSON line that can be ingested by Elasticsearch, Splunk, etc. For example:
+Each line contains a JSON line that can be ingested by services like Elasticsearch and Splunk.
+Line breaks have been added to this example for legibility:
```json
-{"method":"GET","path":"/gitlab/gitlab-foss/issues/1234","format":"html","controller":"Projects::IssuesController","action":"show","status":200,"duration":229.03,"view":174.07,"db":13.24,"time":"2017-08-08T20:15:54.821Z","params":[{"key":"param_key","value":"param_value"}],"remote_ip":"18.245.0.1","user_id":1,"username":"admin","gitaly_calls":76,"gitaly_duration":7.41,"queue_duration": 112.47}
+{
+ "method":"GET",
+ "path":"/gitlab/gitlab-foss/issues/1234",
+ "format":"html",
+ "controller":"Projects::IssuesController",
+ "action":"show",
+ "status":200,
+ "duration":229.03,
+ "view":174.07,
+ "db":13.24,
+ "time":"2017-08-08T20:15:54.821Z",
+ "params":[{"key":"param_key","value":"param_value"}],
+ "remote_ip":"18.245.0.1",
+ "user_id":1,
+ "username":"admin",
+ "gitaly_calls":76,
+ "gitaly_duration":7.41,
+ "queue_duration": 112.47
+}
```
-In this example, you can see this was a GET request for a specific
-issue. Notice each line also contains performance data. All times are in
+This example was a GET request for a specific
+issue. Each line also contains performance data, with times in
milliseconds:
1. `duration`: total time taken to retrieve the request
@@ -37,10 +55,10 @@ milliseconds:
1. `gitaly_calls`: total number of calls made to Gitaly
1. `gitaly_duration`: total time taken by Gitaly calls
-User clone/fetch activity using http transport appears in this log as `action: git_upload_pack`.
+User clone and fetch activity using HTTP transport appears in this log as `action: git_upload_pack`.
-In addition, the log contains the IP address from which the request originated
-(`remote_ip`) as well as the user's ID (`user_id`), and username (`username`).
+In addition, the log contains the originating IP address,
+(`remote_ip`),the user's ID (`user_id`), and username (`username`).
NOTE: **Note:** Starting with GitLab 12.5, if an error occurs, an
`exception` field is included with `class`, `message`, and
@@ -90,11 +108,11 @@ installations from source. (When GitLab is running in an environment
other than production, the corresponding logfile is shown here.)
It contains information about all performed requests. You can see the
-URL and type of request, IP address and what exactly parts of code were
-involved to service this particular request. Also you can see all SQL
-request that have been performed and how much time it took. This task is
+URL and type of request, IP address, and what parts of code were
+involved to service this particular request. Also, you can see all SQL
+requests performed, and how much time each took. This task is
more useful for GitLab contributors and developers. Use part of this log
-file when you are going to report bug. For example:
+file when you're reporting bugs. For example:
```plaintext
Started GET "/gitlabhq/yaml_db/tree/master" for 168.111.56.1 at 2015-02-12 19:34:53 +0200
@@ -114,26 +132,44 @@ Processing by Projects::TreeController#show as HTML
Completed 200 OK in 166ms (Views: 117.4ms | ActiveRecord: 27.2ms)
```
-In this example we can see that server processed an HTTP request with URL
-`/gitlabhq/yaml_db/tree/master` from IP 168.111.56.1 at 2015-02-12
-19:34:53 +0200. Also we can see that request was processed by
-`Projects::TreeController`.
+In this example, the server processed an HTTP request with URL
+`/gitlabhq/yaml_db/tree/master` from IP `168.111.56.1` at `2015-02-12 19:34:53 +0200`.
+The request was processed by `Projects::TreeController`.
## `api_json.log`
> Introduced in GitLab 10.0.
This file lives in
-`/var/log/gitlab/gitlab-rails/api_json.log` for Omnibus GitLab packages or in
+`/var/log/gitlab/gitlab-rails/api_json.log` for Omnibus GitLab packages, or in
`/home/git/gitlab/log/api_json.log` for installations from source.
It helps you see requests made directly to the API. For example:
```json
-{"time":"2018-10-29T12:49:42.123Z","severity":"INFO","duration":709.08,"db":14.59,"view":694.49,"status":200,"method":"GET","path":"/api/v4/projects","params":[{"key":"action","value":"git-upload-pack"},{"key":"changes","value":"_any"},{"key":"key_id","value":"secret"},{"key":"secret_token","value":"[FILTERED]"}],"host":"localhost","remote_ip":"::1","ua":"Ruby","route":"/api/:version/projects","user_id":1,"username":"root","queue_duration":100.31,"gitaly_calls":30,"gitaly_duration":5.36}
+{
+ "time":"2018-10-29T12:49:42.123Z",
+ "severity":"INFO",
+ "duration":709.08,
+ "db":14.59,
+ "view":694.49,
+ "status":200,
+ "method":"GET",
+ "path":"/api/v4/projects",
+ "params":[{"key":"action","value":"git-upload-pack"},{"key":"changes","value":"_any"},{"key":"key_id","value":"secret"},{"key":"secret_token","value":"[FILTERED]"}],
+ "host":"localhost",
+ "remote_ip":"::1",
+ "ua":"Ruby",
+ "route":"/api/:version/projects",
+ "user_id":1,
+ "username":"root",
+ "queue_duration":100.31,
+ "gitaly_calls":30,
+ "gitaly_duration":5.36
+}
```
-This entry above shows an access to an internal endpoint to check whether an
+This entry shows an access to an internal endpoint to check whether an
associated SSH key can download the project in question via a `git fetch` or
`git clone`. In this example, we see:
@@ -141,7 +177,7 @@ associated SSH key can download the project in question via a `git fetch` or
1. `queue_duration`: total time in milliseconds that the request was queued inside GitLab Workhorse
1. `method`: The HTTP method used to make the request
1. `path`: The relative path of the query
-1. `params`: Key-value pairs passed in a query string or HTTP body. Sensitive parameters (e.g. passwords, tokens, etc.) are filtered out.
+1. `params`: Key-value pairs passed in a query string or HTTP body. Sensitive parameters (such as passwords and tokens) are filtered out.
1. `ua`: The User-Agent of the requester
## `application.log`
@@ -172,8 +208,18 @@ installations from source.
It contains the JSON version of the logs in `application.log` like the example below:
``` json
-{"severity":"INFO","time":"2020-01-14T13:35:15.466Z","correlation_id":"3823a1550b64417f9c9ed8ee0f48087e","message":"User \"Administrator\" (admin@example.com) was created"}
-{"severity":"INFO","time":"2020-01-14T13:35:15.466Z","correlation_id":"78e3df10c9a18745243d524540bd5be4","message":"Project \"project133\" was removed"}
+{
+ "severity":"INFO",
+ "time":"2020-01-14T13:35:15.466Z",
+ "correlation_id":"3823a1550b64417f9c9ed8ee0f48087e",
+ "message":"User \"Administrator\" (admin@example.com) was created"
+}
+{
+ "severity":"INFO",
+ "time":"2020-01-14T13:35:15.466Z",
+ "correlation_id":"78e3df10c9a18745243d524540bd5be4",
+ "message":"Project \"project133\" was removed"
+}
```
## `integrations_json.log`
@@ -182,11 +228,28 @@ This file lives in `/var/log/gitlab/gitlab-rails/integrations_json.log` for
Omnibus GitLab packages or in `/home/git/gitlab/log/integrations_json.log` for
installations from source.
-It contains information about [integrations](../user/project/integrations/project_services.md) activities such as Jira, Asana and Irker services. It uses JSON format like the example below:
+It contains information about [integrations](../user/project/integrations/project_services.md) activities such as Jira, Asana, and Irker services. It uses JSON format like the example below:
```json
-{"severity":"ERROR","time":"2018-09-06T14:56:20.439Z","service_class":"JiraService","project_id":8,"project_path":"h5bp/html5-boilerplate","message":"Error sending message","client_url":"http://jira.gitlap.com:8080","error":"execution expired"}
-{"severity":"INFO","time":"2018-09-06T17:15:16.365Z","service_class":"JiraService","project_id":3,"project_path":"namespace2/project2","message":"Successfully posted","client_url":"http://jira.example.com"}
+{
+ "severity":"ERROR",
+ "time":"2018-09-06T14:56:20.439Z",
+ "service_class":"JiraService",
+ "project_id":8,
+ "project_path":"h5bp/html5-boilerplate",
+ "message":"Error sending message",
+ "client_url":"http://jira.gitlap.com:8080",
+ "error":"execution expired"
+}
+{
+ "severity":"INFO",
+ "time":"2018-09-06T17:15:16.365Z",
+ "service_class":"JiraService",
+ "project_id":3,
+ "project_path":"namespace2/project2",
+ "message":"Successfully posted",
+ "client_url":"http://jira.example.com"
+}
```
## `kubernetes.log`
@@ -202,12 +265,32 @@ It logs information related to the Kubernetes Integration including errors
during installing cluster applications on your GitLab managed Kubernetes
clusters.
-Each line contains a JSON line that can be ingested by Elasticsearch, Splunk,
-etc. For example:
+Each line contains a JSON line that can be ingested by services like Elasticsearch and Splunk.
+Line breaks have been added to the following example for clarity:
```json
-{"severity":"ERROR","time":"2018-11-23T15:14:54.652Z","exception":"Kubeclient::HttpError","error_code":401,"service":"Clusters::Applications::CheckInstallationProgressService","app_id":14,"project_ids":[1],"group_ids":[],"message":"Unauthorized"}
-{"severity":"ERROR","time":"2018-11-23T15:42:11.647Z","exception":"Kubeclient::HttpError","error_code":null,"service":"Clusters::Applications::InstallService","app_id":2,"project_ids":[19],"group_ids":[],"message":"SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate)"}
+{
+ "severity":"ERROR",
+ "time":"2018-11-23T15:14:54.652Z",
+ "exception":"Kubeclient::HttpError",
+ "error_code":401,
+ "service":"Clusters::Applications::CheckInstallationProgressService",
+ "app_id":14,
+ "project_ids":[1],
+ "group_ids":[],
+ "message":"Unauthorized"
+}
+{
+ "severity":"ERROR",
+ "time":"2018-11-23T15:42:11.647Z",
+ "exception":"Kubeclient::HttpError",
+ "error_code":null,
+ "service":"Clusters::Applications::InstallService",
+ "app_id":2,
+ "project_ids":[19],
+ "group_ids":[],
+ "message":"SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate)"
+}
```
## `git_json.log`
@@ -220,8 +303,8 @@ NOTE: **Note:**
After 12.2, this file was renamed from `githost.log` to
`git_json.log` and stored in JSON format.
-GitLab has to interact with Git repositories but in some rare cases
-something can go wrong and in this case you will know what exactly
+GitLab has to interact with Git repositories, but in some rare cases
+something can go wrong, and in this case you will know what exactly
happened. This log file contains all failed requests from GitLab to Git
repositories. In the majority of cases this file will be useful for developers
only. For example:
@@ -244,9 +327,20 @@ installations from source.
Changes to group or project settings are logged to this file. For example:
```json
-{"severity":"INFO","time":"2018-10-17T17:38:22.523Z","author_id":3,"entity_id":2,"entity_type":"Project","change":"visibility","from":"Private","to":"Public","author_name":"John Doe4","target_id":2,"target_type":"Project","target_details":"namespace2/project2"}
-{"severity":"INFO","time":"2018-10-17T17:38:22.830Z","author_id":5,"entity_id":3,"entity_type":"Project","change":"name","from":"John Doe7 / project3","to":"John Doe7 / new name","author_name":"John Doe6","target_id":3,"target_type":"Project","target_details":"namespace3/project3"}
-{"severity":"INFO","time":"2018-10-17T17:38:23.175Z","author_id":7,"entity_id":4,"entity_type":"Project","change":"path","from":"","to":"namespace4/newpath","author_name":"John Doe8","target_id":4,"target_type":"Project","target_details":"namespace4/newpath"}
+{
+ "severity":"INFO",
+ "time":"2018-10-17T17:38:22.523Z",
+ "author_id":3,
+ "entity_id":2,
+ "entity_type":"Project",
+ "change":"visibility",
+ "from":"Private",
+ "to":"Public",
+ "author_name":"John Doe4",
+ "target_id":2,
+ "target_type":"Project",
+ "target_details":"namespace2/project2"
+}
```
## `sidekiq.log`
@@ -268,7 +362,27 @@ Instead of the format above, you can opt to generate JSON logs for
Sidekiq. For example:
```json
-{"severity":"INFO","time":"2018-04-03T22:57:22.071Z","queue":"cronjob:update_all_mirrors","args":[],"class":"UpdateAllMirrorsWorker","retry":false,"queue_namespace":"cronjob","jid":"06aeaa3b0aadacf9981f368e","created_at":"2018-04-03T22:57:21.930Z","enqueued_at":"2018-04-03T22:57:21.931Z","pid":10077,"message":"UpdateAllMirrorsWorker JID-06aeaa3b0aadacf9981f368e: done: 0.139 sec","job_status":"done","duration":0.139,"completed_at":"2018-04-03T22:57:22.071Z","db_duration":0.05,"db_duration_s":0.0005,"gitaly_duration":0,"gitaly_calls":0}
+{
+ "severity":"INFO",
+ "time":"2018-04-03T22:57:22.071Z",
+ "queue":"cronjob:update_all_mirrors",
+ "args":[],
+ "class":"UpdateAllMirrorsWorker",
+ "retry":false,
+ "queue_namespace":"cronjob",
+ "jid":"06aeaa3b0aadacf9981f368e",
+ "created_at":"2018-04-03T22:57:21.930Z",
+ "enqueued_at":"2018-04-03T22:57:21.931Z",
+ "pid":10077,
+ "message":"UpdateAllMirrorsWorker JID-06aeaa3b0aadacf9981f368e: done: 0.139 sec",
+ "job_status":"done",
+ "duration":0.139,
+ "completed_at":"2018-04-03T22:57:22.071Z",
+ "db_duration":0.05,
+ "db_duration_s":0.0005,
+ "gitaly_duration":0,
+ "gitaly_calls":0
+}
```
For Omnibus GitLab installations, add the configuration option:
@@ -292,8 +406,8 @@ This file lives in `/var/log/gitlab/gitaly/gitlab-shell.log` for
Omnibus GitLab packages or in `/home/git/gitaly/gitlab-shell.log` for
installations from source.
-NOTE: **Note**
-For GitLab 12.5 and earlier the file lives in `/var/log/gitlab/gitlab-shell/gitlab-shell.log`.
+NOTE: **Note:**
+For GitLab 12.5 and earlier, the file lives in `/var/log/gitlab/gitlab-shell/gitlab-shell.log`.
GitLab Shell is used by GitLab for executing Git commands and provide
SSH access to Git repositories. For example:
@@ -363,7 +477,7 @@ This log records:
- [Protected paths] abusive requests.
NOTE: **Note:**
-From [%12.1](https://gitlab.com/gitlab-org/gitlab-foss/issues/62756), user id and username are also
+From [%12.1](https://gitlab.com/gitlab-org/gitlab-foss/issues/62756), user ID and username are also
recorded on this log, if available.
## `graphql_json.log`
@@ -411,13 +525,13 @@ was initiated, such as `1509705644.log`
## `sidekiq_exporter.log` and `web_exporter.log`
If Prometheus metrics and the Sidekiq Exporter are both enabled, Sidekiq will
-start a Web server and listen to the defined port (default: 8082). Access logs
+start a Web server and listen to the defined port (default: `8082`). Access logs
will be generated in `/var/log/gitlab/gitlab-rails/sidekiq_exporter.log` for
Omnibus GitLab packages or in `/home/git/gitlab/log/sidekiq_exporter.log` for
installations from source.
If Prometheus metrics and the Web Exporter are both enabled, Unicorn/Puma will
-start a Web server and listen to the defined port (default: 8083). Access logs
+start a Web server and listen to the defined port (default: `8083`). Access logs
will be generated in `/var/log/gitlab/gitlab-rails/web_exporter.log` for
Omnibus GitLab packages or in `/home/git/gitlab/log/web_exporter.log` for
installations from source.
@@ -427,7 +541,7 @@ installations from source.
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/15442) in GitLab 12.3.
Contains details of GitLab's [Database Load Balancing](database_load_balancing.md).
-It is stored at:
+It's stored at:
- `/var/log/gitlab/gitlab-rails/database_load_balancing.log` for Omnibus GitLab packages.
- `/home/git/gitlab/log/database_load_balancing.log` for installations from source.
@@ -444,11 +558,21 @@ from source.
It logs information related to the Elasticsearch Integration including
errors during indexing or searching Elasticsearch.
-Each line contains a JSON line that can be ingested by Elasticsearch, Splunk,
-etc. For example:
+Each line contains a JSON line that can be ingested by services like Elasticsearch and Splunk.
+Line breaks have been added to the following example line for clarity:
```json
-{"severity":"DEBUG","time":"2019-10-17T06:23:13.227Z","correlation_id":null,"message":"redacted_search_result","class_name":"Milestone","id":2,"ability":"read_milestone","current_user_id":2,"query":"project"}
+{
+ "severity":"DEBUG",
+ "time":"2019-10-17T06:23:13.227Z",
+ "correlation_id":null,
+ "message":"redacted_search_result",
+ "class_name":"Milestone",
+ "id":2,
+ "ability":"read_milestone",
+ "current_user_id":2,
+ "query":"project"
+}
```
## `exceptions_json.log`
@@ -460,7 +584,7 @@ This file lives in
packages or in `/home/git/gitlab/log/exceptions_json.log` for installations
from source.
-It logs the information about exceptions being tracked by `Gitlab::ErrorTracking` which provides standard and consistent way of [processing rescued exceptions](https://gitlab.com/gitlab-org/gitlab/blob/master/doc/development/logging.md#exception-handling).
+It logs the information about exceptions being tracked by `Gitlab::ErrorTracking` which provides a standard and consistent way of [processing rescued exceptions](https://gitlab.com/gitlab-org/gitlab/blob/master/doc/development/logging.md#exception-handling).
Each line contains a JSON line that can be ingested by Elasticsearch. For example:
diff --git a/doc/administration/monitoring/prometheus/index.md b/doc/administration/monitoring/prometheus/index.md
index 03ea7656d83..87114c154a2 100644
--- a/doc/administration/monitoring/prometheus/index.md
+++ b/doc/administration/monitoring/prometheus/index.md
@@ -7,7 +7,7 @@
> they got added. For installations from source you will have to install them
> yourself. Over subsequent releases additional GitLab metrics will be captured.
> - Prometheus services are on by default with GitLab 9.0.
-> - Prometheus and its exporters do not authenticate users, and will be available
+> - Prometheus and its exporters don't authenticate users, and will be available
> to anyone who can access them.
[Prometheus] is a powerful time-series monitoring service, providing a flexible
@@ -18,7 +18,7 @@ access to high quality time-series monitoring of GitLab services.
## Overview
Prometheus works by periodically connecting to data sources and collecting their
-performance metrics via the [various exporters](#bundled-software-metrics). To view
+performance metrics through the [various exporters](#bundled-software-metrics). To view
and work with the monitoring data, you can either
[connect directly to Prometheus](#viewing-performance-metrics) or utilize a
dashboard tool like [Grafana](https://grafana.com).
@@ -26,11 +26,11 @@ dashboard tool like [Grafana](https://grafana.com).
## Configuring Prometheus
NOTE: **Note:**
-For installations from source you'll have to install and configure it yourself.
+For installations from source, you'll have to install and configure it yourself.
Prometheus and its exporters are on by default, starting with GitLab 9.0.
Prometheus will run as the `gitlab-prometheus` user and listen on
-`http://localhost:9090`. By default Prometheus is only accessible from the GitLab server itself.
+`http://localhost:9090`. By default, Prometheus is only accessible from the GitLab server itself.
Each exporter will be automatically set up as a
monitoring target for Prometheus, unless individually disabled.
@@ -51,7 +51,7 @@ To disable Prometheus and all of its exporters, as well as any added in the futu
NOTE: **Note:**
The following change was added in [GitLab Omnibus 8.17][1261]. Although possible,
it's not recommended to change the port Prometheus listens
-on as this might affect or conflict with other services running on the GitLab
+on, as this might affect or conflict with other services running on the GitLab
server. Proceed at your own risk.
In order to access Prometheus from outside the GitLab server you will need to
@@ -65,7 +65,7 @@ To change the address/port that Prometheus listens on:
prometheus['listen_address'] = 'localhost:9090'
```
- Replace `localhost:9090` with the address/port you want Prometheus to
+ Replace `localhost:9090` with the address or port you want Prometheus to
listen on. If you would like to allow access to Prometheus to hosts other
than `localhost`, leave out the host, or use `0.0.0.0` to allow public access:
@@ -106,7 +106,7 @@ prometheus['scrape_configs'] = [
### Using an external Prometheus server
NOTE: **Note:**
-Prometheus and most exporters do not support authentication. We do not recommend exposing them outside the local network.
+Prometheus and most exporters don't support authentication. We don't recommend exposing them outside the local network.
A few configuration changes are required to allow GitLab to be monitored by an external Prometheus server. External servers are recommended for highly available deployments of GitLab with multiple nodes.
@@ -151,7 +151,7 @@ To use an external Prometheus server:
}
```
-1. [Reconfigure GitLab][reconfigure] to apply the changes
+1. [Reconfigure GitLab][reconfigure] to apply the changes.
1. Edit the Prometheus server's configuration file.
1. Add each node's exporters to the Prometheus server's
[scrape target configuration](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#%3Cscrape_config%3E).
@@ -223,9 +223,9 @@ some workarounds: using a separate FQDN, using server IP, using a separate brows
having [NGINX proxy it][nginx-custom-config].
The performance data collected by Prometheus can be viewed directly in the
-Prometheus console or through a compatible dashboard tool.
+Prometheus console, or through a compatible dashboard tool.
The Prometheus interface provides a [flexible query language](https://prometheus.io/docs/prometheus/latest/querying/basics/)
-to work with the collected data where you can visualize their output.
+to work with the collected data where you can visualize the output.
For a more fully featured dashboard, Grafana can be used and has
[official support for Prometheus][prom-grafana].
@@ -238,23 +238,23 @@ Sample Prometheus queries:
## Prometheus as a Grafana data source
-Grafana allows you to import Prometheus performance metrics as a data source
-and render the metrics as graphs and dashboards which is helpful with visualisation.
+Grafana allows you to import Prometheus performance metrics as a data source,
+and render the metrics as graphs and dashboards, which is helpful with visualization.
To add a Prometheus dashboard for a single server GitLab setup:
1. Create a new data source in Grafana.
-1. Name your data source i.e GitLab.
+1. Name your data source (such as GitLab).
1. Select `Prometheus` in the type dropdown box.
-1. Add your Prometheus listen address as the URL and set access to `Browser`.
+1. Add your Prometheus listen address as the URL, and set access to `Browser`.
1. Set the HTTP method to `GET`.
-1. Save & Test your configuration to verify that it works.
+1. Save and test your configuration to verify that it works.
## GitLab metrics
> Introduced in GitLab 9.3.
-GitLab monitors its own internal service metrics, and makes them available at the `/-/metrics` endpoint. Unlike other exporters, this endpoint requires authentication as it is available on the same URL and port as user traffic.
+GitLab monitors its own internal service metrics, and makes them available at the `/-/metrics` endpoint. Unlike other exporters, this endpoint requires authentication as it's available on the same URL and port as user traffic.
[âž” Read more about the GitLab Metrics.](gitlab_metrics.md)
@@ -265,8 +265,8 @@ export Prometheus metrics.
### Node exporter
-The node exporter allows you to measure various machine resources such as
-memory, disk and CPU utilization.
+The node exporter allows you to measure various machine resources, such as
+memory, disk, and CPU utilization.
[âž” Read more about the node exporter.](node_exporter.md)
@@ -310,7 +310,7 @@ If your GitLab server is running within Kubernetes, Prometheus will collect metr
To disable the monitoring of Kubernetes:
1. Edit `/etc/gitlab/gitlab.rb`.
-1. Add or find and uncomment the following line and set it to `false`:
+1. Add (or find and uncomment) the following line and set it to `false`:
```ruby
prometheus['monitor_kubernetes'] = false
diff --git a/doc/api/merge_trains.md b/doc/api/merge_trains.md
new file mode 100644
index 00000000000..7fff09474df
--- /dev/null
+++ b/doc/api/merge_trains.md
@@ -0,0 +1,80 @@
+# Merge Trains API **(PREMIUM)**
+
+> - [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/36146) in GitLab 12.9.
+> - Using this API you can consume GitLab's [Merge Train](../ci/merge_request_pipelines/pipelines_for_merged_results/merge_trains/index.md) entries.
+
+Every API call to merge trains must be authenticated with Developer or higher [permissions](link-to-permissions-doc).
+
+If a user is not a member of a project and the project is private, a `GET` request on that project will result to a `404` status code.
+
+If Merge Trains is not available for the project, a `403` status code will return.
+
+## Merge Trains API pagination
+
+By default, `GET` requests return 20 results at a time because the API results
+are paginated.
+
+Read more on [pagination](README.md#pagination).
+
+## List Merge Trains for a project
+
+Get all Merge Trains of the requested project:
+
+```txt
+GET /projects/:id/merge_trains
+GET /projects/:id/merge_trains?scope=complete
+```
+
+| Attribute | Type | Required | Description |
+| ------------------- | ---------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------- |
+| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding). |
+| `scope` | string | no | Return Merge Trains filtered by the given scope. Available scopes are `active` (to be merged) and `complete` (have been merged). |
+| `sort` | string | no | Return Merge Trains sorted in `asc` or `desc` order. Default is `desc`. |
+
+```shell
+curl --header "PRIVATE-TOKEN: <your_access_token>" https://gitlab.example.com/api/v4/projects/1/merge_trains
+```
+
+Example response:
+
+```json
+[
+ {
+ "id": 110,
+ "merge_request": {
+ "id": 126,
+ "iid": 59,
+ "project_id": 20,
+ "title": "Test MR 1580978354",
+ "description": "",
+ "state": "merged",
+ "created_at": "2020-02-06T08:39:14.883Z",
+ "updated_at": "2020-02-06T08:40:57.038Z",
+ "web_url": "http://local.gitlab.test:8181/root/merge-train-race-condition/-/merge_requests/59"
+ },
+ "user": {
+ "id": 1,
+ "name": "Administrator",
+ "username": "root",
+ "state": "active",
+ "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
+ "web_url": "http://local.gitlab.test:8181/root"
+ },
+ "pipeline": {
+ "id": 246,
+ "sha": "bcc17a8ffd51be1afe45605e714085df28b80b13",
+ "ref": "refs/merge-requests/59/train",
+ "status": "success",
+ "created_at": "2020-02-06T08:40:42.410Z",
+ "updated_at": "2020-02-06T08:40:46.912Z",
+ "web_url": "http://local.gitlab.test:8181/root/merge-train-race-condition/pipelines/246"
+ },
+ "created_at": "2020-02-06T08:39:47.217Z",
+ "updated_at": "2020-02-06T08:40:57.720Z",
+ "target_branch": "feature-1580973432",
+ "status": "merged",
+ "merged_at": "2020-02-06T08:40:57.719Z",
+ "duration": 70
+ }
+]
+```
diff --git a/doc/development/adding_database_indexes.md b/doc/development/adding_database_indexes.md
index 3ddb15fa290..01b621b6631 100644
--- a/doc/development/adding_database_indexes.md
+++ b/doc/development/adding_database_indexes.md
@@ -73,7 +73,7 @@ especially the case for small tables.
If a table is expected to grow in size and you expect your query has to filter
out a lot of rows you may want to consider adding an index. If the table size is
-very small (e.g. only a handful of rows) or any existing indexes filter out
+very small (e.g. less than `1,000` records) or any existing indexes filter out
enough rows you may _not_ want to add a new index.
## Maintenance Overhead
diff --git a/doc/development/migration_style_guide.md b/doc/development/migration_style_guide.md
index 2c9ad8c00cf..c15e51c2b9d 100644
--- a/doc/development/migration_style_guide.md
+++ b/doc/development/migration_style_guide.md
@@ -304,10 +304,16 @@ combining it with other operations that don't require `disable_ddl_transaction!`
## Adding indexes
-If you need to add a unique index, please keep in mind there is the possibility
-of existing duplicates being present in the database. This means that should
-always _first_ add a migration that removes any duplicates, before adding the
-unique index.
+Before adding an index, consider if this one is necessary. There are situations in which an index
+might not be required, like:
+
+- The table is small (less than `1,000` records) and it's not expected to exponentially grow in size.
+- Any existing indexes filter out enough rows.
+- The reduction in query timings after the index is added is not significant.
+
+Additionally, wide indexes are not required to match all filter criteria of queries, we just need
+to cover enough columns so that the index lookup has a small enough selectivity. Please review our
+[Adding Database indexes](adding_database_indexes.md) guide for more details.
When adding an index to a non-empty table make sure to use the method
`add_concurrent_index` instead of the regular `add_index` method.
@@ -334,6 +340,11 @@ class MyMigration < ActiveRecord::Migration[4.2]
end
```
+If you need to add a unique index, please keep in mind there is the possibility
+of existing duplicates being present in the database. This means that should
+always _first_ add a migration that removes any duplicates, before adding the
+unique index.
+
For a small table (such as an empty one or one with less than `1,000` records),
it is recommended to use `add_index` in a single-transaction migration, combining it with other
operations that don't require `disable_ddl_transaction!`.
diff --git a/doc/user/project/clusters/kubernetes_pod_logs.md b/doc/user/project/clusters/kubernetes_pod_logs.md
index a36b712ae76..76622380e92 100644
--- a/doc/user/project/clusters/kubernetes_pod_logs.md
+++ b/doc/user/project/clusters/kubernetes_pod_logs.md
@@ -29,7 +29,7 @@ You can access them in two ways.
> [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/22011) in GitLab 12.5.
-Go to **Operations > Pod logs** on the sidebar menu.
+Go to **{cloud-gear}** **Operations > Pod logs** on the sidebar menu.
![Sidebar menu](img/sidebar_menu_pod_logs_v12_5.png)
@@ -37,7 +37,7 @@ Go to **Operations > Pod logs** on the sidebar menu.
Logs can be displayed by clicking on a specific pod from [Deploy Boards](../deploy_boards.md):
-1. Go to **Operations > Environments** and find the environment which contains the desired pod, like `production`.
+1. Go to **{cloud-gear}** **Operations > Environments** and find the environment which contains the desired pod, like `production`.
1. On the **Environments** page, you should see the status of the environment's pods with [Deploy Boards](../deploy_boards.md).
1. When mousing over the list of pods, a tooltip will appear with the exact pod name and status.
![Deploy Boards pod list](img/pod_logs_deploy_board.png)
@@ -45,7 +45,7 @@ Logs can be displayed by clicking on a specific pod from [Deploy Boards](../depl
### Logs view
-The logs view will contain the last 500 lines for a pod, and has control to filter via:
+The logs view will contain the last 500 lines for a pod, and has control to filter through:
- Pods.
- [From GitLab 12.4](https://gitlab.com/gitlab-org/gitlab/issues/5769), environments.
@@ -62,14 +62,14 @@ Support for historical data is coming [in a future release](https://gitlab.com/g
When you enable [Elastic Stack](../../clusters/applications.md#elastic-stack) on your cluster, you can filter by date.
-Click on "Show last" to see the available options.
+Click on **Show last** to see the available options.
### Full text search
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/21656) in GitLab 12.7.
When you enable [Elastic Stack](../../clusters/applications.md#elastic-stack) on your cluster,
-you can search the content of your logs via a search bar.
+you can search the content of your logs through a search bar.
The search is passed on to Elasticsearch using the [simple_query_string](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html)
Elasticsearch function, which supports the following operators:
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 001fb92ec52..6c3b8cb8dd8 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -359,6 +359,10 @@ module API
render_api_error!('405 Method Not Allowed', 405)
end
+ def service_unavailable!
+ render_api_error!('503 Service Unavailable', 503)
+ end
+
def conflict!(message = nil)
render_api_error!(message || '409 Conflict', 409)
end
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index c369fbda9d2..c5b7e6f6baa 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -21618,12 +21618,18 @@ msgstr ""
msgid "VulnerabilityManagement|Confirm"
msgstr ""
+msgid "VulnerabilityManagement|Create issue"
+msgstr ""
+
msgid "VulnerabilityManagement|Dismiss"
msgstr ""
msgid "VulnerabilityManagement|Resolved"
msgstr ""
+msgid "VulnerabilityManagement|Something went wrong, could not create an issue."
+msgstr ""
+
msgid "VulnerabilityManagement|Something went wrong, could not update vulnerability state."
msgstr ""
diff --git a/spec/features/merge_request/user_views_diffs_spec.rb b/spec/features/merge_request/user_views_diffs_spec.rb
index e0e4058dd47..cd0cf1cc78a 100644
--- a/spec/features/merge_request/user_views_diffs_spec.rb
+++ b/spec/features/merge_request/user_views_diffs_spec.rb
@@ -7,10 +7,11 @@ describe 'User views diffs', :js do
create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test')
end
let(:project) { create(:project, :public, :repository) }
+ let(:view) { 'inline' }
before do
stub_feature_flags(diffs_batch_load: false)
- visit(diffs_project_merge_request_path(project, merge_request))
+ visit(diffs_project_merge_request_path(project, merge_request, view: view))
wait_for_requests
@@ -20,12 +21,20 @@ describe 'User views diffs', :js do
shared_examples 'unfold diffs' do
it 'unfolds diffs upwards' do
first('.js-unfold').click
- expect(find('.file-holder[id="a5cc2925ca8258af241be7e5b0381edf30266302"] .text-file')).to have_content('.bundle')
+
+ page.within('.file-holder[id="a5cc2925ca8258af241be7e5b0381edf30266302"]') do
+ expect(find('.text-file')).to have_content('.bundle')
+ expect(page).to have_selector('.new_line [data-linenumber="1"]', count: 1)
+ end
end
- it 'unfolds diffs to the start' do
- first('.js-unfold-all').click
- expect(find('.file-holder[id="a5cc2925ca8258af241be7e5b0381edf30266302"] .text-file')).to have_content('.rbc')
+ it 'unfolds diffs in the middle' do
+ page.within('.file-holder[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd"]') do
+ all('.js-unfold-all')[1].click
+
+ expect(page).to have_selector('.new_line [data-linenumber="24"]', count: 1)
+ expect(page).not_to have_selector('.new_line [data-linenumber="1"]')
+ end
end
it 'unfolds diffs downwards' do
@@ -66,13 +75,7 @@ describe 'User views diffs', :js do
end
context 'when in the side-by-side view' do
- before do
- find('.js-show-diff-settings').click
-
- click_button 'Side-by-side'
-
- wait_for_requests
- end
+ let(:view) { 'parallel' }
it 'shows diffs in parallel' do
expect(page).to have_css('.parallel')
diff --git a/spec/fixtures/api/schemas/public_api/v4/merge_request_simple.json b/spec/fixtures/api/schemas/public_api/v4/merge_request_simple.json
new file mode 100644
index 00000000000..45507e3e400
--- /dev/null
+++ b/spec/fixtures/api/schemas/public_api/v4/merge_request_simple.json
@@ -0,0 +1,26 @@
+{
+ "type": "object",
+ "properties" : {
+ "properties" : {
+ "id": { "type": "integer" },
+ "iid": { "type": "integer" },
+ "project_id": { "type": "integer" },
+ "title": { "type": "string" },
+ "description": { "type": ["string", "null"] },
+ "state": { "type": "string" },
+ "created_at": { "type": "date" },
+ "updated_at": { "type": "date" },
+ "web_url": { "type": "uri" }
+ },
+ "required": [
+ "id", "iid", "project_id", "title", "description",
+ "state", "created_at", "updated_at", "web_url"
+ ],
+ "head_pipeline": {
+ "oneOf": [
+ { "type": "null" },
+ { "$ref": "pipeline/detail.json" }
+ ]
+ }
+ }
+}
diff --git a/spec/javascripts/diffs/components/diff_expansion_cell_spec.js b/spec/javascripts/diffs/components/diff_expansion_cell_spec.js
index e8ff6778512..9a5048d9332 100644
--- a/spec/javascripts/diffs/components/diff_expansion_cell_spec.js
+++ b/spec/javascripts/diffs/components/diff_expansion_cell_spec.js
@@ -1,64 +1,229 @@
import Vue from 'vue';
+import { cloneDeep } from 'lodash';
import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
import { createStore } from '~/mr_notes/stores';
import DiffExpansionCell from '~/diffs/components/diff_expansion_cell.vue';
+import { getPreviousLineIndex } from '~/diffs/store/utils';
+import { INLINE_DIFF_VIEW_TYPE, PARALLEL_DIFF_VIEW_TYPE } from '~/diffs/constants';
import diffFileMockData from '../mock_data/diff_file';
const EXPAND_UP_CLASS = '.js-unfold';
const EXPAND_DOWN_CLASS = '.js-unfold-down';
const EXPAND_ALL_CLASS = '.js-unfold-all';
+const LINE_TO_USE = 5;
+const lineSources = {
+ [INLINE_DIFF_VIEW_TYPE]: 'highlighted_diff_lines',
+ [PARALLEL_DIFF_VIEW_TYPE]: 'parallel_diff_lines',
+};
+const lineHandlers = {
+ [INLINE_DIFF_VIEW_TYPE]: line => line,
+ [PARALLEL_DIFF_VIEW_TYPE]: line => line.right || line.left,
+};
+
+function makeLoadMoreLinesPayload({
+ sinceLine,
+ toLine,
+ oldLineNumber,
+ diffViewType,
+ fileHash,
+ nextLineNumbers = {},
+ unfold = false,
+ bottom = false,
+ isExpandDown = false,
+}) {
+ return {
+ endpoint: 'contextLinesPath',
+ params: {
+ since: sinceLine,
+ to: toLine,
+ offset: toLine + 1 - oldLineNumber,
+ view: diffViewType,
+ unfold,
+ bottom,
+ },
+ lineNumbers: {
+ oldLineNumber,
+ newLineNumber: toLine + 1,
+ },
+ nextLineNumbers,
+ fileHash,
+ isExpandDown,
+ };
+}
+
+function getLine(file, type, index) {
+ const source = lineSources[type];
+ const handler = lineHandlers[type];
+
+ return handler(file[source][index]);
+}
describe('DiffExpansionCell', () => {
- const matchLine = diffFileMockData.highlighted_diff_lines[5];
+ let mockFile;
+ let mockLine;
+ let store;
+ let vm;
+
+ beforeEach(() => {
+ mockFile = cloneDeep(diffFileMockData);
+ mockLine = getLine(mockFile, INLINE_DIFF_VIEW_TYPE, LINE_TO_USE);
+ store = createStore();
+ store.state.diffs.diffFiles = [mockFile];
+ spyOn(store, 'dispatch').and.returnValue(Promise.resolve());
+ });
const createComponent = (options = {}) => {
const cmp = Vue.extend(DiffExpansionCell);
const defaults = {
- fileHash: diffFileMockData.file_hash,
+ fileHash: mockFile.file_hash,
contextLinesPath: 'contextLinesPath',
- line: matchLine,
+ line: mockLine,
isTop: false,
isBottom: false,
};
const props = Object.assign({}, defaults, options);
- return createComponentWithStore(cmp, createStore(), props).$mount();
+ vm = createComponentWithStore(cmp, store, props).$mount();
};
+ const findExpandUp = () => vm.$el.querySelector(EXPAND_UP_CLASS);
+ const findExpandDown = () => vm.$el.querySelector(EXPAND_DOWN_CLASS);
+ const findExpandAll = () => vm.$el.querySelector(EXPAND_ALL_CLASS);
+
describe('top row', () => {
it('should have "expand up" and "show all" option', () => {
- const vm = createComponent({
+ createComponent({
isTop: true,
});
- const el = vm.$el;
- expect(el.querySelector(EXPAND_UP_CLASS)).not.toBe(null);
- expect(el.querySelector(EXPAND_DOWN_CLASS)).toBe(null);
- expect(el.querySelector(EXPAND_ALL_CLASS)).not.toBe(null);
+ expect(findExpandUp()).not.toBe(null);
+ expect(findExpandDown()).toBe(null);
+ expect(findExpandAll()).not.toBe(null);
});
});
describe('middle row', () => {
it('should have "expand down", "show all", "expand up" option', () => {
- const vm = createComponent();
- const el = vm.$el;
+ createComponent();
- expect(el.querySelector(EXPAND_UP_CLASS)).not.toBe(null);
- expect(el.querySelector(EXPAND_DOWN_CLASS)).not.toBe(null);
- expect(el.querySelector(EXPAND_ALL_CLASS)).not.toBe(null);
+ expect(findExpandUp()).not.toBe(null);
+ expect(findExpandDown()).not.toBe(null);
+ expect(findExpandAll()).not.toBe(null);
});
});
describe('bottom row', () => {
it('should have "expand down" and "show all" option', () => {
- const vm = createComponent({
+ createComponent({
isBottom: true,
});
- const el = vm.$el;
- expect(el.querySelector(EXPAND_UP_CLASS)).toBe(null);
- expect(el.querySelector(EXPAND_DOWN_CLASS)).not.toBe(null);
- expect(el.querySelector(EXPAND_ALL_CLASS)).not.toBe(null);
+ expect(findExpandUp()).toBe(null);
+ expect(findExpandDown()).not.toBe(null);
+ expect(findExpandAll()).not.toBe(null);
+ });
+ });
+
+ describe('any row', () => {
+ [
+ { diffViewType: INLINE_DIFF_VIEW_TYPE, file: { parallel_diff_lines: [] } },
+ { diffViewType: PARALLEL_DIFF_VIEW_TYPE, file: { highlighted_diff_lines: [] } },
+ ].forEach(({ diffViewType, file }) => {
+ describe(`with diffViewType (${diffViewType})`, () => {
+ beforeEach(() => {
+ mockLine = getLine(mockFile, diffViewType, LINE_TO_USE);
+ store.state.diffs.diffFiles = [{ ...mockFile, ...file }];
+ store.state.diffs.diffViewType = diffViewType;
+ });
+
+ it('does not initially dispatch anything', () => {
+ expect(store.dispatch).not.toHaveBeenCalled();
+ });
+
+ it('on expand all clicked, dispatch loadMoreLines', () => {
+ const oldLineNumber = mockLine.meta_data.old_pos;
+ const newLineNumber = mockLine.meta_data.new_pos;
+ const previousIndex = getPreviousLineIndex(diffViewType, mockFile, {
+ oldLineNumber,
+ newLineNumber,
+ });
+
+ createComponent();
+
+ findExpandAll().click();
+
+ expect(store.dispatch).toHaveBeenCalledWith(
+ 'diffs/loadMoreLines',
+ makeLoadMoreLinesPayload({
+ fileHash: mockFile.file_hash,
+ toLine: newLineNumber - 1,
+ sinceLine: previousIndex,
+ oldLineNumber,
+ diffViewType,
+ }),
+ );
+ });
+
+ it('on expand up clicked, dispatch loadMoreLines', () => {
+ mockLine.meta_data.old_pos = 200;
+ mockLine.meta_data.new_pos = 200;
+
+ const oldLineNumber = mockLine.meta_data.old_pos;
+ const newLineNumber = mockLine.meta_data.new_pos;
+
+ createComponent();
+
+ findExpandUp().click();
+
+ expect(store.dispatch).toHaveBeenCalledWith(
+ 'diffs/loadMoreLines',
+ makeLoadMoreLinesPayload({
+ fileHash: mockFile.file_hash,
+ toLine: newLineNumber - 1,
+ sinceLine: 179,
+ oldLineNumber,
+ diffViewType,
+ unfold: true,
+ }),
+ );
+ });
+
+ it('on expand down clicked, dispatch loadMoreLines', () => {
+ mockFile[lineSources[diffViewType]][LINE_TO_USE + 1] = cloneDeep(
+ mockFile[lineSources[diffViewType]][LINE_TO_USE],
+ );
+ const nextLine = getLine(mockFile, diffViewType, LINE_TO_USE + 1);
+
+ nextLine.meta_data.old_pos = 300;
+ nextLine.meta_data.new_pos = 300;
+ mockLine.meta_data.old_pos = 200;
+ mockLine.meta_data.new_pos = 200;
+
+ createComponent();
+
+ findExpandDown().click();
+
+ expect(store.dispatch).toHaveBeenCalledWith('diffs/loadMoreLines', {
+ endpoint: 'contextLinesPath',
+ params: {
+ since: 1,
+ to: 21, // the load amount, plus 1 line
+ offset: 0,
+ view: diffViewType,
+ unfold: true,
+ bottom: true,
+ },
+ lineNumbers: {
+ // when expanding down, these are based on the previous line, 0, in this case
+ oldLineNumber: 0,
+ newLineNumber: 0,
+ },
+ nextLineNumbers: { old_line: 200, new_line: 200 },
+ fileHash: mockFile.file_hash,
+ isExpandDown: true,
+ });
+ });
+ });
});
});
});
diff --git a/spec/javascripts/diffs/store/mutations_spec.js b/spec/javascripts/diffs/store/mutations_spec.js
index cb89a89e216..ffe5d89e615 100644
--- a/spec/javascripts/diffs/store/mutations_spec.js
+++ b/spec/javascripts/diffs/store/mutations_spec.js
@@ -167,7 +167,7 @@ describe('DiffsStoreMutations', () => {
highlighted_diff_lines: [],
parallel_diff_lines: [],
};
- const state = { diffFiles: [diffFile] };
+ const state = { diffFiles: [diffFile], diffViewType: 'viewType' };
const lines = [{ old_line: 1, new_line: 1 }];
const findDiffFileSpy = spyOnDependency(mutations, 'findDiffFile').and.returnValue(diffFile);
@@ -195,6 +195,7 @@ describe('DiffsStoreMutations', () => {
expect(addContextLinesSpy).toHaveBeenCalledWith({
inlineLines: diffFile.highlighted_diff_lines,
parallelLines: diffFile.parallel_diff_lines,
+ diffViewType: 'viewType',
contextLines: options.contextLines,
bottom: options.params.bottom,
lineNumbers: options.lineNumbers,
diff --git a/spec/javascripts/diffs/store/utils_spec.js b/spec/javascripts/diffs/store/utils_spec.js
index 051820cedfa..223c4d7e40b 100644
--- a/spec/javascripts/diffs/store/utils_spec.js
+++ b/spec/javascripts/diffs/store/utils_spec.js
@@ -1,3 +1,4 @@
+import { clone } from 'lodash';
import * as utils from '~/diffs/store/utils';
import {
LINE_POSITION_LEFT,
@@ -8,6 +9,7 @@ import {
NEW_LINE_TYPE,
OLD_LINE_TYPE,
MATCH_LINE_TYPE,
+ INLINE_DIFF_VIEW_TYPE,
PARALLEL_DIFF_VIEW_TYPE,
} from '~/diffs/constants';
import { MERGE_REQUEST_NOTEABLE_TYPE } from '~/notes/constants';
@@ -47,7 +49,38 @@ describe('DiffsStoreUtils', () => {
describe('findIndexInParallelLines', () => {
it('should return correct index for given line numbers', () => {
- expectSet(utils.findIndexInParallelLines, getDiffFileMock().parallel_diff_lines, {});
+ expectSet(utils.findIndexInParallelLines, getDiffFileMock().parallel_diff_lines, []);
+ });
+ });
+ });
+
+ describe('getPreviousLineIndex', () => {
+ [
+ { diffViewType: INLINE_DIFF_VIEW_TYPE, file: { parallel_diff_lines: [] } },
+ { diffViewType: PARALLEL_DIFF_VIEW_TYPE, file: { highlighted_diff_lines: [] } },
+ ].forEach(({ diffViewType, file }) => {
+ describe(`with diffViewType (${diffViewType}) in split diffs`, () => {
+ let diffFile;
+
+ beforeEach(() => {
+ diffFile = { ...clone(diffFileMockData), ...file };
+ });
+
+ it('should return the correct previous line number', () => {
+ const emptyLines =
+ diffViewType === INLINE_DIFF_VIEW_TYPE
+ ? diffFile.parallel_diff_lines
+ : diffFile.highlighted_diff_lines;
+
+ // This expectation asserts that we cannot possibly be using the opposite view type lines in the next expectation
+ expect(emptyLines.length).toBe(0);
+ expect(
+ utils.getPreviousLineIndex(diffViewType, diffFile, {
+ oldLineNumber: 3,
+ newLineNumber: 5,
+ }),
+ ).toBe(4);
+ });
});
});
});
@@ -80,44 +113,59 @@ describe('DiffsStoreUtils', () => {
});
describe('addContextLines', () => {
- it('should add context lines', () => {
- const diffFile = getDiffFileMock();
- const inlineLines = diffFile.highlighted_diff_lines;
- const parallelLines = diffFile.parallel_diff_lines;
- const lineNumbers = { oldLineNumber: 3, newLineNumber: 5 };
- const contextLines = [{ lineNumber: 42, line_code: '123' }];
- const options = { inlineLines, parallelLines, contextLines, lineNumbers };
- const inlineIndex = utils.findIndexInInlineLines(inlineLines, lineNumbers);
- const parallelIndex = utils.findIndexInParallelLines(parallelLines, lineNumbers);
- const normalizedParallelLine = {
- left: options.contextLines[0],
- right: options.contextLines[0],
- line_code: '123',
- };
-
- utils.addContextLines(options);
-
- expect(inlineLines[inlineIndex]).toEqual(contextLines[0]);
- expect(parallelLines[parallelIndex]).toEqual(normalizedParallelLine);
- });
-
- it('should add context lines properly with bottom parameter', () => {
- const diffFile = getDiffFileMock();
- const inlineLines = diffFile.highlighted_diff_lines;
- const parallelLines = diffFile.parallel_diff_lines;
- const lineNumbers = { oldLineNumber: 3, newLineNumber: 5 };
- const contextLines = [{ lineNumber: 42, line_code: '123' }];
- const options = { inlineLines, parallelLines, contextLines, lineNumbers, bottom: true };
- const normalizedParallelLine = {
- left: options.contextLines[0],
- right: options.contextLines[0],
- line_code: '123',
- };
-
- utils.addContextLines(options);
+ [INLINE_DIFF_VIEW_TYPE, PARALLEL_DIFF_VIEW_TYPE].forEach(diffViewType => {
+ it(`should add context lines for ${diffViewType}`, () => {
+ const diffFile = getDiffFileMock();
+ const inlineLines = diffFile.highlighted_diff_lines;
+ const parallelLines = diffFile.parallel_diff_lines;
+ const lineNumbers = { oldLineNumber: 3, newLineNumber: 5 };
+ const contextLines = [{ lineNumber: 42, line_code: '123' }];
+ const options = { inlineLines, parallelLines, contextLines, lineNumbers, diffViewType };
+ const inlineIndex = utils.findIndexInInlineLines(inlineLines, lineNumbers);
+ const parallelIndex = utils.findIndexInParallelLines(parallelLines, lineNumbers);
+ const normalizedParallelLine = {
+ left: options.contextLines[0],
+ right: options.contextLines[0],
+ line_code: '123',
+ };
+
+ utils.addContextLines(options);
+
+ if (diffViewType === INLINE_DIFF_VIEW_TYPE) {
+ expect(inlineLines[inlineIndex]).toEqual(contextLines[0]);
+ } else {
+ expect(parallelLines[parallelIndex]).toEqual(normalizedParallelLine);
+ }
+ });
- expect(inlineLines[inlineLines.length - 1]).toEqual(contextLines[0]);
- expect(parallelLines[parallelLines.length - 1]).toEqual(normalizedParallelLine);
+ it(`should add context lines properly with bottom parameter for ${diffViewType}`, () => {
+ const diffFile = getDiffFileMock();
+ const inlineLines = diffFile.highlighted_diff_lines;
+ const parallelLines = diffFile.parallel_diff_lines;
+ const lineNumbers = { oldLineNumber: 3, newLineNumber: 5 };
+ const contextLines = [{ lineNumber: 42, line_code: '123' }];
+ const options = {
+ inlineLines,
+ parallelLines,
+ contextLines,
+ lineNumbers,
+ bottom: true,
+ diffViewType,
+ };
+ const normalizedParallelLine = {
+ left: options.contextLines[0],
+ right: options.contextLines[0],
+ line_code: '123',
+ };
+
+ utils.addContextLines(options);
+
+ if (diffViewType === INLINE_DIFF_VIEW_TYPE) {
+ expect(inlineLines[inlineLines.length - 1]).toEqual(contextLines[0]);
+ } else {
+ expect(parallelLines[parallelLines.length - 1]).toEqual(normalizedParallelLine);
+ }
+ });
});
});
diff --git a/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb b/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb
index f91927412cb..b1d56b57596 100644
--- a/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb
+++ b/spec/lib/banzai/filter/inline_metrics_redactor_filter_spec.rb
@@ -5,8 +5,7 @@ require 'spec_helper'
describe Banzai::Filter::InlineMetricsRedactorFilter do
include FilterSpecHelper
- set(:project) { create(:project) }
-
+ let_it_be(:project) { create(:project) }
let(:url) { urls.metrics_dashboard_project_environment_url(project, 1, embedded: true) }
let(:input) { %(<a href="#{url}">example</a>) }
let(:doc) { filter(input) }
diff --git a/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb b/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb
index 47ea273ef3a..448422b15e3 100644
--- a/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb
+++ b/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb
@@ -121,7 +121,7 @@ describe Banzai::Pipeline::GfmPipeline do
end
describe 'emoji in references' do
- set(:project) { create(:project, :public) }
+ let_it_be(:project) { create(:project, :public) }
let(:emoji) { '💯' }
it 'renders a label reference with emoji inside' do
diff --git a/spec/lib/event_filter_spec.rb b/spec/lib/event_filter_spec.rb
index 21b8f726425..e35698f6030 100644
--- a/spec/lib/event_filter_spec.rb
+++ b/spec/lib/event_filter_spec.rb
@@ -18,17 +18,16 @@ describe EventFilter do
end
describe '#apply_filter' do
- set(:public_project) { create(:project, :public) }
-
- set(:push_event) { create(:push_event, project: public_project) }
- set(:merged_event) { create(:event, :merged, project: public_project, target: public_project) }
- set(:created_event) { create(:event, :created, project: public_project, target: create(:issue, project: public_project)) }
- set(:updated_event) { create(:event, :updated, project: public_project, target: create(:issue, project: public_project)) }
- set(:closed_event) { create(:event, :closed, project: public_project, target: create(:issue, project: public_project)) }
- set(:reopened_event) { create(:event, :reopened, project: public_project, target: create(:issue, project: public_project)) }
- set(:comments_event) { create(:event, :commented, project: public_project, target: public_project) }
- set(:joined_event) { create(:event, :joined, project: public_project, target: public_project) }
- set(:left_event) { create(:event, :left, project: public_project, target: public_project) }
+ let_it_be(:public_project) { create(:project, :public) }
+ let_it_be(:push_event) { create(:push_event, project: public_project) }
+ let_it_be(:merged_event) { create(:event, :merged, project: public_project, target: public_project) }
+ let_it_be(:created_event) { create(:event, :created, project: public_project, target: create(:issue, project: public_project)) }
+ let_it_be(:updated_event) { create(:event, :updated, project: public_project, target: create(:issue, project: public_project)) }
+ let_it_be(:closed_event) { create(:event, :closed, project: public_project, target: create(:issue, project: public_project)) }
+ let_it_be(:reopened_event) { create(:event, :reopened, project: public_project, target: create(:issue, project: public_project)) }
+ let_it_be(:comments_event) { create(:event, :commented, project: public_project, target: public_project) }
+ let_it_be(:joined_event) { create(:event, :joined, project: public_project, target: public_project) }
+ let_it_be(:left_event) { create(:event, :left, project: public_project, target: public_project) }
let(:filtered_events) { described_class.new(filter).apply_filter(Event.all) }
diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb
index ed763f63756..209ba68ccbc 100644
--- a/spec/lib/gitlab/auth_spec.rb
+++ b/spec/lib/gitlab/auth_spec.rb
@@ -3,10 +3,9 @@
require 'spec_helper'
describe Gitlab::Auth, :use_clean_rails_memory_store_caching do
+ let_it_be(:project) { create(:project) }
let(:gl_auth) { described_class }
- set(:project) { create(:project) }
-
describe 'constants' do
it 'API_SCOPES contains all scopes for API access' do
expect(subject::API_SCOPES).to eq %i[api read_user]
diff --git a/spec/lib/gitlab/checks/force_push_spec.rb b/spec/lib/gitlab/checks/force_push_spec.rb
index 9432be083d3..334dd8635a3 100644
--- a/spec/lib/gitlab/checks/force_push_spec.rb
+++ b/spec/lib/gitlab/checks/force_push_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe Gitlab::Checks::ForcePush do
- set(:project) { create(:project, :repository) }
+ let_it_be(:project) { create(:project, :repository) }
describe '.force_push?' do
it 'returns false if the repo is empty' do
diff --git a/spec/lib/gitlab/ci/build/policy/changes_spec.rb b/spec/lib/gitlab/ci/build/policy/changes_spec.rb
index 48ac2e4e657..07f52605929 100644
--- a/spec/lib/gitlab/ci/build/policy/changes_spec.rb
+++ b/spec/lib/gitlab/ci/build/policy/changes_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe Gitlab::Ci::Build::Policy::Changes do
- set(:project) { create(:project) }
+ let_it_be(:project) { create(:project) }
describe '#satisfied_by?' do
describe 'paths matching' do
@@ -89,7 +89,7 @@ describe Gitlab::Ci::Build::Policy::Changes do
end
describe 'gitaly integration' do
- set(:project) { create(:project, :repository) }
+ let_it_be(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_empty_pipeline, project: project,
@@ -119,6 +119,7 @@ describe Gitlab::Ci::Build::Policy::Changes do
end
context 'when branch is created' do
+ let_it_be(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_empty_pipeline, project: project,
ref: 'feature',
diff --git a/spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb b/spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb
index bc2e6fe6b8d..6d96bdc30c7 100644
--- a/spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb
+++ b/spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb
@@ -18,7 +18,7 @@ describe Gitlab::Ci::Build::Policy::Kubernetes do
end
context 'when kubernetes service is inactive' do
- set(:project) { create(:project) }
+ let_it_be(:project) { create(:project) }
it 'is not satisfied by a pipeline without kubernetes available' do
expect(described_class.new('active'))
diff --git a/spec/lib/gitlab/ci/build/policy/variables_spec.rb b/spec/lib/gitlab/ci/build/policy/variables_spec.rb
index 66f2cb640b9..0e75726b81c 100644
--- a/spec/lib/gitlab/ci/build/policy/variables_spec.rb
+++ b/spec/lib/gitlab/ci/build/policy/variables_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe Gitlab::Ci::Build::Policy::Variables do
- set(:project) { create(:project) }
+ let_it_be(:project) { create(:project) }
let(:pipeline) do
build(:ci_empty_pipeline, project: project, ref: 'master', source: :push)
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 95f0c93e758..53205a18762 100644
--- a/spec/lib/gitlab/ci/config/external/file/local_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/file/local_spec.rb
@@ -3,13 +3,11 @@
require 'spec_helper'
describe Gitlab::Ci::Config::External::File::Local do
- set(:project) { create(:project, :repository) }
- set(:user) { create(:user) }
-
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:user) { create(:user) }
let(:sha) { '12345' }
let(:context_params) { { project: project, sha: sha, user: user } }
let(:context) { Gitlab::Ci::Config::External::Context.new(**context_params) }
-
let(:params) { { local: location } }
let(:local_file) { described_class.new(params, context) }
diff --git a/spec/lib/gitlab/ci/config/external/file/project_spec.rb b/spec/lib/gitlab/ci/config/external/file/project_spec.rb
index 0aea3a59b33..77a71f9972b 100644
--- a/spec/lib/gitlab/ci/config/external/file/project_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/file/project_spec.rb
@@ -3,10 +3,9 @@
require 'spec_helper'
describe Gitlab::Ci::Config::External::File::Project do
- set(:context_project) { create(:project) }
- set(:project) { create(:project, :repository) }
- set(:user) { create(:user) }
-
+ let_it_be(:context_project) { create(:project) }
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:user) { create(:user) }
let(:context_user) { user }
let(:context_params) { { project: context_project, sha: '12345', user: context_user } }
let(:context) { Gitlab::Ci::Config::External::Context.new(**context_params) }
diff --git a/spec/lib/gitlab/ci/config/external/file/template_spec.rb b/spec/lib/gitlab/ci/config/external/file/template_spec.rb
index ee1660e4dfd..7ea5aadac52 100644
--- a/spec/lib/gitlab/ci/config/external/file/template_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/file/template_spec.rb
@@ -3,14 +3,12 @@
require 'spec_helper'
describe Gitlab::Ci::Config::External::File::Template do
- set(:project) { create(:project) }
- set(:user) { create(:user) }
-
+ let_it_be(:project) { create(:project) }
+ let_it_be(:user) { create(:user) }
let(:context_params) { { project: project, sha: '12345', user: user } }
let(:context) { Gitlab::Ci::Config::External::Context.new(**context_params) }
let(:template) { 'Auto-DevOps.gitlab-ci.yml' }
let(:params) { { template: template } }
-
let(:template_file) { described_class.new(params, context) }
before do
diff --git a/spec/lib/gitlab/ci/config/external/mapper_spec.rb b/spec/lib/gitlab/ci/config/external/mapper_spec.rb
index 2a5f62f7e74..6839002c3ab 100644
--- a/spec/lib/gitlab/ci/config/external/mapper_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/mapper_spec.rb
@@ -5,9 +5,8 @@ require 'spec_helper'
describe Gitlab::Ci::Config::External::Mapper do
include StubRequests
- set(:project) { create(:project, :repository) }
- set(:user) { create(:user) }
-
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:user) { create(:user) }
let(:local_file) { '/lib/gitlab/ci/templates/non-existent-file.yml' }
let(:remote_url) { 'https://gitlab.com/gitlab-org/gitlab-foss/blob/1234/.gitlab-ci-1.yml' }
let(:template_file) { 'Auto-DevOps.gitlab-ci.yml' }
diff --git a/spec/lib/gitlab/ci/config/external/processor_spec.rb b/spec/lib/gitlab/ci/config/external/processor_spec.rb
index bb2d3f66972..ff08d4703fe 100644
--- a/spec/lib/gitlab/ci/config/external/processor_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/processor_spec.rb
@@ -5,10 +5,9 @@ require 'spec_helper'
describe Gitlab::Ci::Config::External::Processor do
include StubRequests
- set(:project) { create(:project, :repository) }
- set(:another_project) { create(:project, :repository) }
- set(:user) { create(:user) }
-
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:another_project) { create(:project, :repository) }
+ let_it_be(:user) { create(:user) }
let(:sha) { '12345' }
let(:context_params) { { project: project, sha: sha, user: user } }
let(:context) { Gitlab::Ci::Config::External::Context.new(**context_params) }
diff --git a/spec/lib/gitlab/ci/config_spec.rb b/spec/lib/gitlab/ci/config_spec.rb
index 63a36995284..525335cfea9 100644
--- a/spec/lib/gitlab/ci/config_spec.rb
+++ b/spec/lib/gitlab/ci/config_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
describe Gitlab::Ci::Config do
include StubRequests
- set(:user) { create(:user) }
+ let_it_be(:user) { create(:user) }
before do
allow_next_instance_of(Gitlab::Ci::Config::External::Context) do |instance|
diff --git a/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
index b81094f8b4a..094563bd979 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
@@ -3,8 +3,8 @@
require 'spec_helper'
describe Gitlab::Ci::Pipeline::Chain::Build do
- set(:project) { create(:project, :repository) }
- set(:user) { create(:user, developer_projects: [project]) }
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:user) { create(:user, developer_projects: [project]) }
let(:pipeline) { Ci::Pipeline.new }
let(:variables_attributes) do
diff --git a/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
index 5775e934cfd..56707f4e6e4 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe Gitlab::Ci::Pipeline::Chain::Command do
- set(:project) { create(:project, :repository) }
+ let_it_be(:project) { create(:project, :repository) }
describe '#initialize' do
subject do
diff --git a/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
index 650ab193997..f18ad05a704 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
@@ -3,8 +3,8 @@
require 'spec_helper'
describe Gitlab::Ci::Pipeline::Chain::Create do
- set(:project) { create(:project) }
- set(:user) { create(:user) }
+ let_it_be(:project) { create(:project) }
+ let_it_be(:user) { create(:user) }
let(:pipeline) do
build(:ci_empty_pipeline, project: project, ref: 'master')
diff --git a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
index 52e9432dc92..6dab5679e60 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
@@ -3,8 +3,8 @@
require 'spec_helper'
describe Gitlab::Ci::Pipeline::Chain::Populate do
- set(:project) { create(:project, :repository) }
- set(:user) { create(:user) }
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:user) { create(:user) }
let(:pipeline) do
build(:ci_pipeline, project: project, ref: 'master', user: user)
diff --git a/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb
index 9cb59442dfd..9033b71b19f 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb
@@ -3,9 +3,8 @@
require 'spec_helper'
describe Gitlab::Ci::Pipeline::Chain::Sequence do
- set(:project) { create(:project) }
- set(:user) { create(:user) }
-
+ let_it_be(:project) { create(:project) }
+ let_it_be(:user) { create(:user) }
let(:pipeline) { build_stubbed(:ci_pipeline) }
let(:command) { Gitlab::Ci::Pipeline::Chain::Command.new }
let(:first_step) { spy('first step') }
diff --git a/spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb
index fe46633ed1b..55d6d35340e 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb
@@ -3,9 +3,9 @@
require 'spec_helper'
describe Gitlab::Ci::Pipeline::Chain::Skip do
- set(:project) { create(:project) }
- set(:user) { create(:user) }
- set(:pipeline) { create(:ci_pipeline, project: project) }
+ let_it_be(:project, reload: true) { create(:project) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:pipeline, reload: true) { create(:ci_pipeline, project: project) }
let(:command) do
Gitlab::Ci::Pipeline::Chain::Command.new(
diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb
index 24d3beb35b9..8bf8bdf08ff 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb
@@ -3,8 +3,8 @@
require 'spec_helper'
describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do
- set(:project) { create(:project, :repository) }
- set(:user) { create(:user) }
+ let_it_be(:project, reload: true) { create(:project, :repository) }
+ let_it_be(:user) { create(:user) }
let(:pipeline) do
build_stubbed(:ci_pipeline, project: project)
diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb
index b866355906e..83271007ab0 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb
@@ -3,10 +3,9 @@
require 'spec_helper'
describe Gitlab::Ci::Pipeline::Chain::Validate::Repository do
- set(:project) { create(:project, :repository) }
- set(:user) { create(:user) }
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:user) { create(:user) }
let(:pipeline) { build_stubbed(:ci_pipeline) }
-
let!(:step) { described_class.new(pipeline, command) }
before do
diff --git a/spec/lib/gitlab/ci/status/composite_spec.rb b/spec/lib/gitlab/ci/status/composite_spec.rb
index 857483a9e0a..b9d4c39e0c2 100644
--- a/spec/lib/gitlab/ci/status/composite_spec.rb
+++ b/spec/lib/gitlab/ci/status/composite_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe Gitlab::Ci::Status::Composite do
- set(:pipeline) { create(:ci_pipeline) }
+ let_it_be(:pipeline) { create(:ci_pipeline) }
before(:all) do
@statuses = HasStatus::STATUSES_ENUM.map do |status, idx|
diff --git a/spec/lib/gitlab/ci/trace/chunked_io_spec.rb b/spec/lib/gitlab/ci/trace/chunked_io_spec.rb
index 1b034656e7d..92b3e5562a9 100644
--- a/spec/lib/gitlab/ci/trace/chunked_io_spec.rb
+++ b/spec/lib/gitlab/ci/trace/chunked_io_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
include ChunkedIOHelpers
- set(:build) { create(:ci_build, :running) }
+ let_it_be(:build) { create(:ci_build, :running) }
let(:chunked_io) { described_class.new(build) }
before do
diff --git a/spec/lib/gitlab/ci/trace/stream_spec.rb b/spec/lib/gitlab/ci/trace/stream_spec.rb
index 45b59541ce6..ea79073840d 100644
--- a/spec/lib/gitlab/ci/trace/stream_spec.rb
+++ b/spec/lib/gitlab/ci/trace/stream_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
- set(:build) { create(:ci_build, :running) }
+ let_it_be(:build) { create(:ci_build, :running) }
before do
stub_feature_flags(ci_enable_live_trace: true)
diff --git a/spec/lib/gitlab/data_builder/wiki_page_spec.rb b/spec/lib/gitlab/data_builder/wiki_page_spec.rb
index 404d54bf2da..ae338e30a69 100644
--- a/spec/lib/gitlab/data_builder/wiki_page_spec.rb
+++ b/spec/lib/gitlab/data_builder/wiki_page_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe Gitlab::DataBuilder::WikiPage do
- set(:project) { create(:project, :repository, :wiki_repo) }
+ let_it_be(:project) { create(:project, :repository, :wiki_repo) }
let(:wiki_page) { create(:wiki_page, wiki: project.wiki) }
let(:user) { create(:user) }
diff --git a/spec/lib/gitlab/git/lfs_changes_spec.rb b/spec/lib/gitlab/git/lfs_changes_spec.rb
index a99e8c4f60c..adc63401b89 100644
--- a/spec/lib/gitlab/git/lfs_changes_spec.rb
+++ b/spec/lib/gitlab/git/lfs_changes_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe Gitlab::Git::LfsChanges do
- set(:project) { create(:project, :repository) }
+ let_it_be(:project) { create(:project, :repository) }
let(:newrev) { '54fcc214b94e78d7a41a9a8fe6d87a5e59500e51' }
let(:blob_object_id) { '0c304a93cb8430108629bbbcaa27db3343299bc0' }
diff --git a/spec/lib/gitlab/git/merge_base_spec.rb b/spec/lib/gitlab/git/merge_base_spec.rb
index fa95a1664ea..d92b13c5023 100644
--- a/spec/lib/gitlab/git/merge_base_spec.rb
+++ b/spec/lib/gitlab/git/merge_base_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe Gitlab::Git::MergeBase do
- set(:project) { create(:project, :repository) }
+ let_it_be(:project) { create(:project, :repository) }
let(:repository) { project.repository }
subject(:merge_base) { described_class.new(repository, refs) }
diff --git a/spec/lib/gitlab/git/push_spec.rb b/spec/lib/gitlab/git/push_spec.rb
index 32c4c1c82d4..c09e8a085df 100644
--- a/spec/lib/gitlab/git/push_spec.rb
+++ b/spec/lib/gitlab/git/push_spec.rb
@@ -3,8 +3,7 @@
require 'spec_helper'
describe Gitlab::Git::Push do
- set(:project) { create(:project, :repository) }
-
+ let_it_be(:project) { create(:project, :repository) }
let(:oldrev) { project.commit('HEAD~2').id }
let(:newrev) { project.commit.id }
let(:ref) { 'refs/heads/some-branch' }
diff --git a/spec/lib/gitlab/git_post_receive_spec.rb b/spec/lib/gitlab/git_post_receive_spec.rb
index f0df3794e29..0e25a616810 100644
--- a/spec/lib/gitlab/git_post_receive_spec.rb
+++ b/spec/lib/gitlab/git_post_receive_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe ::Gitlab::GitPostReceive do
- set(:project) { create(:project, :repository) }
+ let_it_be(:project) { create(:project, :repository) }
subject { described_class.new(project, "project-#{project.id}", changes.dup, {}) }
diff --git a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb
index d4337c51279..563e0590482 100644
--- a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb
@@ -3,10 +3,10 @@
require 'spec_helper'
describe Gitlab::GitalyClient::OperationService do
- set(:project) { create(:project, :repository) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project, :repository) }
let(:repository) { project.repository.raw }
let(:client) { described_class.new(repository) }
- set(:user) { create(:user) }
let(:gitaly_user) { Gitlab::Git::User.from_gitlab(user).to_gitaly }
describe '#user_create_branch' do
diff --git a/spec/lib/gitlab/global_id_spec.rb b/spec/lib/gitlab/global_id_spec.rb
index d35b5da0b75..719743ed5dc 100644
--- a/spec/lib/gitlab/global_id_spec.rb
+++ b/spec/lib/gitlab/global_id_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
describe Gitlab::GlobalId do
describe '.build' do
- set(:object) { create(:issue) }
+ let_it_be(:object) { create(:issue) }
it 'returns a standard GlobalId if only object is passed' do
expect(described_class.build(object).to_s).to eq(object.to_global_id.to_s)
diff --git a/spec/lib/gitlab/graphql/loaders/batch_lfs_oid_loader_spec.rb b/spec/lib/gitlab/graphql/loaders/batch_lfs_oid_loader_spec.rb
index 1e8de144b8d..b3d57c899d5 100644
--- a/spec/lib/gitlab/graphql/loaders/batch_lfs_oid_loader_spec.rb
+++ b/spec/lib/gitlab/graphql/loaders/batch_lfs_oid_loader_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
describe Gitlab::Graphql::Loaders::BatchLfsOidLoader do
include GraphqlHelpers
- set(:project) { create(:project, :repository) }
+ let_it_be(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:blob) { Gitlab::Graphql::Representation::TreeEntry.new(repository.blob_at('master', 'files/lfs/lfs_object.iso'), repository) }
let(:otherblob) { Gitlab::Graphql::Representation::TreeEntry.new(repository.blob_at('master', 'README'), repository) }
diff --git a/spec/lib/gitlab/hashed_storage/migrator_spec.rb b/spec/lib/gitlab/hashed_storage/migrator_spec.rb
index f3cbb811679..c59b152a982 100644
--- a/spec/lib/gitlab/hashed_storage/migrator_spec.rb
+++ b/spec/lib/gitlab/hashed_storage/migrator_spec.rb
@@ -186,7 +186,7 @@ describe Gitlab::HashedStorage::Migrator, :redis do
end
describe 'migration_pending?' do
- set(:project) { create(:project, :empty_repo) }
+ let_it_be(:project) { create(:project, :empty_repo) }
it 'returns true when there are MigratorWorker jobs scheduled' do
Sidekiq::Testing.disable! do
@@ -210,7 +210,7 @@ describe Gitlab::HashedStorage::Migrator, :redis do
end
describe 'rollback_pending?' do
- set(:project) { create(:project, :empty_repo) }
+ let_it_be(:project) { create(:project, :empty_repo) }
it 'returns true when there are RollbackerWorker jobs scheduled' do
Sidekiq::Testing.disable! do
diff --git a/spec/lib/gitlab/hook_data/issuable_builder_spec.rb b/spec/lib/gitlab/hook_data/issuable_builder_spec.rb
index 5135c84df19..cff489e0f3b 100644
--- a/spec/lib/gitlab/hook_data/issuable_builder_spec.rb
+++ b/spec/lib/gitlab/hook_data/issuable_builder_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe Gitlab::HookData::IssuableBuilder do
- set(:user) { create(:user) }
+ let_it_be(:user) { create(:user) }
# This shared example requires a `builder` and `user` variable
shared_examples 'issuable hook data' do |kind|
diff --git a/spec/lib/gitlab/hook_data/issue_builder_spec.rb b/spec/lib/gitlab/hook_data/issue_builder_spec.rb
index 8008f3d72b2..168603d6fcc 100644
--- a/spec/lib/gitlab/hook_data/issue_builder_spec.rb
+++ b/spec/lib/gitlab/hook_data/issue_builder_spec.rb
@@ -3,8 +3,8 @@
require 'spec_helper'
describe Gitlab::HookData::IssueBuilder do
- set(:label) { create(:label) }
- set(:issue) { create(:labeled_issue, labels: [label], project: label.project) }
+ let_it_be(:label) { create(:label) }
+ let_it_be(:issue) { create(:labeled_issue, labels: [label], project: label.project) }
let(:builder) { described_class.new(issue) }
describe '#build' do
diff --git a/spec/lib/gitlab/hook_data/merge_request_builder_spec.rb b/spec/lib/gitlab/hook_data/merge_request_builder_spec.rb
index 506354e370c..67fa0a7426a 100644
--- a/spec/lib/gitlab/hook_data/merge_request_builder_spec.rb
+++ b/spec/lib/gitlab/hook_data/merge_request_builder_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe Gitlab::HookData::MergeRequestBuilder do
- set(:merge_request) { create(:merge_request) }
+ let_it_be(:merge_request) { create(:merge_request) }
let(:builder) { described_class.new(merge_request) }
describe '#build' do
diff --git a/spec/lib/gitlab/import/merge_request_helpers_spec.rb b/spec/lib/gitlab/import/merge_request_helpers_spec.rb
index 2b165994152..d81251c4a43 100644
--- a/spec/lib/gitlab/import/merge_request_helpers_spec.rb
+++ b/spec/lib/gitlab/import/merge_request_helpers_spec.rb
@@ -3,8 +3,8 @@
require 'spec_helper'
describe Gitlab::Import::MergeRequestHelpers, type: :helper do
- set(:project) { create(:project, :repository) }
- set(:user) { create(:user) }
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:user) { create(:user) }
describe '.create_merge_request_without_hooks' do
let(:iid) { 42 }
diff --git a/spec/lib/gitlab/import_export/repo_saver_spec.rb b/spec/lib/gitlab/import_export/repo_saver_spec.rb
index fc1f782bfdd..a95d661ec3c 100644
--- a/spec/lib/gitlab/import_export/repo_saver_spec.rb
+++ b/spec/lib/gitlab/import_export/repo_saver_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
describe Gitlab::ImportExport::RepoSaver do
describe 'bundle a project Git repo' do
- set(:user) { create(:user) }
+ let_it_be(:user) { create(:user) }
let!(:project) { create(:project, :repository) }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:shared) { project.import_export_shared }
diff --git a/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb b/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb
index 59a59223d8d..264272d2026 100644
--- a/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb
+++ b/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb
@@ -4,8 +4,8 @@ require 'spec_helper'
describe Gitlab::ImportExport::WikiRepoSaver do
describe 'bundle a wiki Git repo' do
- set(:user) { create(:user) }
- let!(:project) { create(:project, :wiki_repo) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project, :wiki_repo) }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:shared) { project.import_export_shared }
let(:wiki_bundler) { described_class.new(project: project, shared: shared) }
diff --git a/spec/lib/gitlab/json_cache_spec.rb b/spec/lib/gitlab/json_cache_spec.rb
index 9d986abb8dd..9379499f602 100644
--- a/spec/lib/gitlab/json_cache_spec.rb
+++ b/spec/lib/gitlab/json_cache_spec.rb
@@ -3,13 +3,12 @@
require 'spec_helper'
describe Gitlab::JsonCache do
+ let_it_be(:broadcast_message) { create(:broadcast_message) }
let(:backend) { double('backend').as_null_object }
let(:namespace) { 'geo' }
let(:key) { 'foo' }
let(:expanded_key) { "#{namespace}:#{key}:#{Gitlab::VERSION}:#{Rails.version}" }
- set(:broadcast_message) { create(:broadcast_message) }
-
subject(:cache) { described_class.new(namespace: namespace, backend: backend) }
describe '#active?' do
diff --git a/spec/lib/gitlab/language_detection_spec.rb b/spec/lib/gitlab/language_detection_spec.rb
index f558ce0d527..770fe2f80db 100644
--- a/spec/lib/gitlab/language_detection_spec.rb
+++ b/spec/lib/gitlab/language_detection_spec.rb
@@ -3,9 +3,9 @@
require 'spec_helper'
describe Gitlab::LanguageDetection do
- set(:project) { create(:project, :repository) }
- set(:ruby) { create(:programming_language, name: 'Ruby') }
- set(:haskell) { create(:programming_language, name: 'Haskell') }
+ let_it_be(:project) { create(:project, :repository) }
+ let_it_be(:ruby) { create(:programming_language, name: 'Ruby') }
+ let_it_be(:haskell) { create(:programming_language, name: 'Haskell') }
let(:repository) { project.repository }
let(:detection) do
[{ value: 66.63, label: "Ruby", color: "#701516", highlight: "#701516" },
diff --git a/spec/lib/gitlab/metrics/dashboard/finder_spec.rb b/spec/lib/gitlab/metrics/dashboard/finder_spec.rb
index 2d3b61e61ce..d772b0c7a5f 100644
--- a/spec/lib/gitlab/metrics/dashboard/finder_spec.rb
+++ b/spec/lib/gitlab/metrics/dashboard/finder_spec.rb
@@ -5,9 +5,9 @@ require 'spec_helper'
describe Gitlab::Metrics::Dashboard::Finder, :use_clean_rails_memory_store_caching do
include MetricsDashboardHelpers
- set(:project) { create(:project) }
- set(:user) { create(:user) }
- set(:environment) { create(:environment, project: project) }
+ let_it_be(:project) { create(:project) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:environment) { create(:environment, project: project) }
before do
project.add_maintainer(user)
diff --git a/spec/lib/gitlab/phabricator_import/cache/map_spec.rb b/spec/lib/gitlab/phabricator_import/cache/map_spec.rb
index 14a5d40d445..b2a63e4f026 100644
--- a/spec/lib/gitlab/phabricator_import/cache/map_spec.rb
+++ b/spec/lib/gitlab/phabricator_import/cache/map_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe Gitlab::PhabricatorImport::Cache::Map, :clean_gitlab_redis_cache do
- set(:project) { create(:project) }
+ let_it_be(:project) { create(:project) }
let(:redis) { Gitlab::Redis::Cache }
subject(:map) { described_class.new(project) }
diff --git a/spec/lib/gitlab/phabricator_import/issues/task_importer_spec.rb b/spec/lib/gitlab/phabricator_import/issues/task_importer_spec.rb
index 06ed264e781..79f11d7fae6 100644
--- a/spec/lib/gitlab/phabricator_import/issues/task_importer_spec.rb
+++ b/spec/lib/gitlab/phabricator_import/issues/task_importer_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
describe Gitlab::PhabricatorImport::Issues::TaskImporter do
- set(:project) { create(:project) }
+ let_it_be(:project) { create(:project) }
let(:task) do
Gitlab::PhabricatorImport::Representation::Task.new(
{
diff --git a/spec/lib/gitlab/project_template_spec.rb b/spec/lib/gitlab/project_template_spec.rb
index a2e3e2146f3..528eeb0f919 100644
--- a/spec/lib/gitlab/project_template_spec.rb
+++ b/spec/lib/gitlab/project_template_spec.rb
@@ -73,7 +73,7 @@ describe Gitlab::ProjectTemplate do
end
describe 'validate all templates' do
- set(:admin) { create(:admin) }
+ let_it_be(:admin) { create(:admin) }
described_class.all.each do |template|
it "#{template.name} has a valid archive" do
diff --git a/spec/lib/gitlab/repo_path_spec.rb b/spec/lib/gitlab/repo_path_spec.rb
index cffd7cc89e7..2aeb69db2cb 100644
--- a/spec/lib/gitlab/repo_path_spec.rb
+++ b/spec/lib/gitlab/repo_path_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
describe ::Gitlab::RepoPath do
describe '.parse' do
- set(:project) { create(:project, :repository) }
+ let_it_be(:project) { create(:project, :repository) }
context 'a repository storage path' do
it 'parses a full repository path' do
diff --git a/spec/lib/gitlab/sanitizers/exif_spec.rb b/spec/lib/gitlab/sanitizers/exif_spec.rb
index f0b733817b3..58fba673f8e 100644
--- a/spec/lib/gitlab/sanitizers/exif_spec.rb
+++ b/spec/lib/gitlab/sanitizers/exif_spec.rb
@@ -7,9 +7,9 @@ describe Gitlab::Sanitizers::Exif do
describe '#batch_clean' do
context 'with image uploads' do
- set(:upload1) { create(:upload, :with_file, :issuable_upload) }
- set(:upload2) { create(:upload, :with_file, :personal_snippet_upload) }
- set(:upload3) { create(:upload, :with_file, created_at: 3.days.ago) }
+ let_it_be(:upload1) { create(:upload, :with_file, :issuable_upload) }
+ let_it_be(:upload2) { create(:upload, :with_file, :personal_snippet_upload) }
+ let_it_be(:upload3) { create(:upload, :with_file, created_at: 3.days.ago) }
it 'processes all uploads if range ID is not set' do
expect(sanitizer).to receive(:clean).exactly(3).times
diff --git a/spec/lib/gitlab/shell_spec.rb b/spec/lib/gitlab/shell_spec.rb
index 7b8d1b6cd9b..19ffb6440be 100644
--- a/spec/lib/gitlab/shell_spec.rb
+++ b/spec/lib/gitlab/shell_spec.rb
@@ -4,8 +4,7 @@ require 'spec_helper'
require 'stringio'
describe Gitlab::Shell do
- set(:project) { create(:project, :repository) }
-
+ let_it_be(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:gitlab_shell) { described_class.new }
let(:popen_vars) { { 'GIT_TERMINAL_PROMPT' => ENV['GIT_TERMINAL_PROMPT'] } }
diff --git a/spec/lib/gitlab/slash_commands/issue_move_spec.rb b/spec/lib/gitlab/slash_commands/issue_move_spec.rb
index 962ac3668bc..1a45b0e06ba 100644
--- a/spec/lib/gitlab/slash_commands/issue_move_spec.rb
+++ b/spec/lib/gitlab/slash_commands/issue_move_spec.rb
@@ -22,11 +22,11 @@ describe Gitlab::SlashCommands::IssueMove, service: true do
end
describe '#execute' do
- set(:user) { create(:user) }
- set(:issue) { create(:issue) }
- set(:chat_name) { create(:chat_name, user: user) }
- set(:project) { issue.project }
- set(:other_project) { create(:project, namespace: project.namespace) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:issue) { create(:issue) }
+ let_it_be(:chat_name) { create(:chat_name, user: user) }
+ let_it_be(:project) { issue.project }
+ let_it_be(:other_project) { create(:project, namespace: project.namespace) }
before do
[project, other_project].each { |prj| prj.add_maintainer(user) }
diff --git a/spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb b/spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb
index 56b64d32192..7726c3b6a87 100644
--- a/spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb
+++ b/spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb
@@ -3,11 +3,11 @@
require 'spec_helper'
describe Gitlab::SlashCommands::Presenters::IssueMove do
- set(:admin) { create(:admin) }
- set(:project) { create(:project) }
- set(:other_project) { create(:project) }
- set(:old_issue) { create(:issue, project: project) }
- set(:new_issue) { Issues::MoveService.new(project, admin).execute(old_issue, other_project) }
+ let_it_be(:admin) { create(:admin) }
+ let_it_be(:project, reload: true) { create(:project) }
+ let_it_be(:other_project) { create(:project) }
+ let_it_be(:old_issue, reload: true) { create(:issue, project: project) }
+ let(:new_issue) { Issues::MoveService.new(project, admin).execute(old_issue, other_project) }
let(:attachment) { subject[:attachments].first }
subject { described_class.new(new_issue).present(old_issue) }
diff --git a/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb b/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb
index c8f2a37c5d6..cd5cde76b73 100644
--- a/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb
+++ b/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb
@@ -3,8 +3,7 @@
require 'spec_helper'
describe Gitlab::Template::Finders::RepoTemplateFinder do
- set(:project) { create(:project, :repository) }
-
+ let_it_be(:project) { create(:project, :repository) }
let(:categories) { { 'HTML' => 'html' } }
subject(:finder) { described_class.new(project, 'files/', '.html', categories) }
diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb
index 89381057f6b..921ed568b71 100644
--- a/spec/lib/gitlab/workhorse_spec.rb
+++ b/spec/lib/gitlab/workhorse_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
describe Gitlab::Workhorse do
- set(:project) { create(:project, :repository) }
+ let_it_be(:project) { create(:project, :repository) }
let(:repository) { project.repository }
def decode_workhorse_header(array)
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb
index 5ae042e4148..1a64ffea8f4 100644
--- a/spec/support/capybara.rb
+++ b/spec/support/capybara.rb
@@ -17,7 +17,8 @@ JS_CONSOLE_FILTER = Regexp.union([
'"[HMR] Waiting for update signal from WDS..."',
'"[WDS] Hot Module Replacement enabled."',
'"[WDS] Live Reloading enabled."',
- "Download the Vue Devtools extension"
+ 'Download the Vue Devtools extension',
+ 'Download the Apollo DevTools'
])
CAPYBARA_WINDOW_SIZE = [1366, 768].freeze