Commit fca89bb7 authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent 76e9fc7b
...@@ -84,7 +84,6 @@ export default () => { ...@@ -84,7 +84,6 @@ export default () => {
rootPath: $boardApp.dataset.rootPath, rootPath: $boardApp.dataset.rootPath,
bulkUpdatePath: $boardApp.dataset.bulkUpdatePath, bulkUpdatePath: $boardApp.dataset.bulkUpdatePath,
detailIssue: boardsStore.detail, detailIssue: boardsStore.detail,
defaultAvatar: $boardApp.dataset.defaultAvatar,
}, },
computed: { computed: {
detailIssueVisible() { detailIssueVisible() {
...@@ -130,13 +129,10 @@ export default () => { ...@@ -130,13 +129,10 @@ export default () => {
position = -1; position = -1;
} }
boardsStore.addList( boardsStore.addList({
{ ...listObj,
...listObj, position,
position, });
},
this.defaultAvatar,
);
}); });
boardsStore.addBlankState(); boardsStore.addBlankState();
......
export default class ListAssignee { export default class ListAssignee {
constructor(obj, defaultAvatar) { constructor(obj) {
this.id = obj.id; this.id = obj.id;
this.name = obj.name; this.name = obj.name;
this.username = obj.username; this.username = obj.username;
this.avatar = obj.avatar_url || obj.avatar || defaultAvatar; this.avatar = obj.avatar_url || obj.avatar || gon.default_avatar_url;
this.path = obj.path; this.path = obj.path;
this.state = obj.state; this.state = obj.state;
this.webUrl = obj.web_url || obj.webUrl; this.webUrl = obj.web_url || obj.webUrl;
......
...@@ -10,7 +10,7 @@ import IssueProject from './project'; ...@@ -10,7 +10,7 @@ import IssueProject from './project';
import boardsStore from '../stores/boards_store'; import boardsStore from '../stores/boards_store';
class ListIssue { class ListIssue {
constructor(obj, defaultAvatar) { constructor(obj) {
this.subscribed = obj.subscribed; this.subscribed = obj.subscribed;
this.labels = []; this.labels = [];
this.assignees = []; this.assignees = [];
...@@ -22,11 +22,11 @@ class ListIssue { ...@@ -22,11 +22,11 @@ class ListIssue {
this.closed = obj.closed; this.closed = obj.closed;
this.isLoading = {}; this.isLoading = {};
this.refreshData(obj, defaultAvatar); this.refreshData(obj);
} }
refreshData(obj, defaultAvatar) { refreshData(obj) {
boardsStore.refreshIssueData(this, obj, defaultAvatar); boardsStore.refreshIssueData(this, obj);
} }
addLabel(label) { addLabel(label) {
......
...@@ -36,7 +36,7 @@ const TYPES = { ...@@ -36,7 +36,7 @@ const TYPES = {
}; };
class List { class List {
constructor(obj, defaultAvatar) { constructor(obj) {
this.id = obj.id; this.id = obj.id;
this._uid = this.guid(); this._uid = this.guid();
this.position = obj.position; this.position = obj.position;
...@@ -55,7 +55,6 @@ class List { ...@@ -55,7 +55,6 @@ class List {
this.maxIssueCount = Object.hasOwnProperty.call(obj, 'max_issue_count') this.maxIssueCount = Object.hasOwnProperty.call(obj, 'max_issue_count')
? obj.max_issue_count ? obj.max_issue_count
: 0; : 0;
this.defaultAvatar = defaultAvatar;
if (obj.label) { if (obj.label) {
this.label = new ListLabel(obj.label); this.label = new ListLabel(obj.label);
...@@ -156,7 +155,7 @@ class List { ...@@ -156,7 +155,7 @@ class List {
createIssues(data) { createIssues(data) {
data.forEach(issueObj => { data.forEach(issueObj => {
this.addIssue(new ListIssue(issueObj, this.defaultAvatar)); this.addIssue(new ListIssue(issueObj));
}); });
} }
......
...@@ -74,8 +74,8 @@ const boardsStore = { ...@@ -74,8 +74,8 @@ const boardsStore = {
showPage(page) { showPage(page) {
this.state.currentPage = page; this.state.currentPage = page;
}, },
addList(listObj, defaultAvatar) { addList(listObj) {
const list = new List(listObj, defaultAvatar); const list = new List(listObj);
this.state.lists = _.sortBy([...this.state.lists, list], 'position'); this.state.lists = _.sortBy([...this.state.lists, list], 'position');
return list; return list;
...@@ -602,7 +602,7 @@ const boardsStore = { ...@@ -602,7 +602,7 @@ const boardsStore = {
clearMultiSelect() { clearMultiSelect() {
this.multiSelect.list = []; this.multiSelect.list = [];
}, },
refreshIssueData(issue, obj, defaultAvatar) { refreshIssueData(issue, obj) {
issue.id = obj.id; issue.id = obj.id;
issue.iid = obj.iid; issue.iid = obj.iid;
issue.title = obj.title; issue.title = obj.title;
...@@ -631,7 +631,7 @@ const boardsStore = { ...@@ -631,7 +631,7 @@ const boardsStore = {
} }
if (obj.assignees) { if (obj.assignees) {
issue.assignees = obj.assignees.map(a => new ListAssignee(a, defaultAvatar)); issue.assignees = obj.assignees.map(a => new ListAssignee(a));
} }
}, },
}; };
......
<script> <script>
import ItemButton from './button.vue'; import ItemButton from './button.vue';
import { isTextFile } from '~/ide/utils';
export default { export default {
components: { components: {
...@@ -23,29 +24,11 @@ export default { ...@@ -23,29 +24,11 @@ export default {
}, },
}, },
methods: { methods: {
isText(content, fileType) {
const knownBinaryFileTypes = ['image/'];
const knownTextFileTypes = ['text/'];
const isKnownBinaryFileType = knownBinaryFileTypes.find(type => fileType.includes(type));
const isKnownTextFileType = knownTextFileTypes.find(type => fileType.includes(type));
const asciiRegex = /^[ -~\t\n\r]+$/; // tests whether a string contains ascii characters only (ranges from space to tilde, tabs and new lines)
if (isKnownBinaryFileType) {
return false;
}
if (isKnownTextFileType) {
return true;
}
// if it's not a known file type, determine the type by evaluating the file contents
return asciiRegex.test(content);
},
createFile(target, file) { createFile(target, file) {
const { name } = file; const { name } = file;
const encodedContent = target.result.split('base64,')[1]; const encodedContent = target.result.split('base64,')[1];
const rawContent = encodedContent ? atob(encodedContent) : ''; const rawContent = encodedContent ? atob(encodedContent) : '';
const isText = this.isText(rawContent, file.type); const isText = isTextFile(rawContent, file.type, name);
const emitCreateEvent = content => const emitCreateEvent = content =>
this.$emit('create', { this.$emit('create', {
......
import { commitItemIconMap } from './constants'; import { commitItemIconMap } from './constants';
import { languages } from 'monaco-editor';
import { flatten } from 'lodash';
const toLowerCase = x => x.toLowerCase();
const monacoLanguages = languages.getLanguages();
const monacoExtensions = new Set(
flatten(monacoLanguages.map(lang => lang.extensions?.map(toLowerCase) || [])),
);
const monacoMimetypes = new Set(
flatten(monacoLanguages.map(lang => lang.mimetypes?.map(toLowerCase) || [])),
);
const monacoFilenames = new Set(
flatten(monacoLanguages.map(lang => lang.filenames?.map(toLowerCase) || [])),
);
const KNOWN_TYPES = [
{
isText: false,
isMatch(mimeType) {
return mimeType.toLowerCase().includes('image/');
},
},
{
isText: true,
isMatch(mimeType) {
return mimeType.toLowerCase().includes('text/');
},
},
{
isText: true,
isMatch(mimeType, fileName) {
const fileExtension = fileName.includes('.') ? `.${fileName.split('.').pop()}` : '';
return (
monacoExtensions.has(fileExtension.toLowerCase()) ||
monacoMimetypes.has(mimeType.toLowerCase()) ||
monacoFilenames.has(fileName.toLowerCase())
);
},
},
];
export function isTextFile(content, mimeType, fileName) {
const knownType = KNOWN_TYPES.find(type => type.isMatch(mimeType, fileName));
if (knownType) return knownType.isText;
// does the string contain ascii characters only (ranges from space to tilde, tabs and new lines)
const asciiRegex = /^[ -~\t\n\r]+$/;
// for unknown types, determine the type by evaluating the file contents
return asciiRegex.test(content);
}
export const getCommitIconMap = file => { export const getCommitIconMap = file => {
if (file.deleted) { if (file.deleted) {
......
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
GlTooltip, GlTooltip,
GlTooltipDirective, GlTooltipDirective,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { __ } from '~/locale'; import { __, n__ } from '~/locale';
import Icon from '~/vue_shared/components/icon.vue'; import Icon from '~/vue_shared/components/icon.vue';
import MonitorTimeSeriesChart from './charts/time_series.vue'; import MonitorTimeSeriesChart from './charts/time_series.vue';
import MonitorAnomalyChart from './charts/anomaly.vue'; import MonitorAnomalyChart from './charts/anomaly.vue';
...@@ -120,6 +120,12 @@ export default { ...@@ -120,6 +120,12 @@ export default {
!this.isPanelType('stacked-column') !this.isPanelType('stacked-column')
); );
}, },
editCustomMetricLink() {
return this.graphData?.metrics[0].edit_path;
},
editCustomMetricLinkText() {
return n__('Metrics|Edit metric', 'Metrics|Edit metrics', this.graphData.metrics.length);
},
}, },
mounted() { mounted() {
this.refreshTitleTooltip(); this.refreshTitleTooltip();
...@@ -195,7 +201,13 @@ export default { ...@@ -195,7 +201,13 @@ export default {
<template slot="button-content"> <template slot="button-content">
<icon name="ellipsis_v" class="text-secondary" /> <icon name="ellipsis_v" class="text-secondary" />
</template> </template>
<gl-dropdown-item
v-if="editCustomMetricLink"
ref="editMetricLink"
:href="editCustomMetricLink"
>
{{ editCustomMetricLinkText }}
</gl-dropdown-item>
<gl-dropdown-item <gl-dropdown-item
v-if="logsPathWithTimeRange" v-if="logsPathWithTimeRange"
ref="viewLogsLink" ref="viewLogsLink"
......
...@@ -15,7 +15,6 @@ module BoardsHelper ...@@ -15,7 +15,6 @@ module BoardsHelper
root_path: root_path, root_path: root_path,
full_path: full_path, full_path: full_path,
bulk_update_path: @bulk_issues_path, bulk_update_path: @bulk_issues_path,
default_avatar: image_path(default_avatar),
time_tracking_limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s, time_tracking_limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s,
recent_boards_endpoint: recent_boards_path recent_boards_endpoint: recent_boards_path
} }
......
...@@ -95,6 +95,7 @@ class GroupPolicy < BasePolicy ...@@ -95,6 +95,7 @@ class GroupPolicy < BasePolicy
enable :admin_cluster enable :admin_cluster
enable :destroy_deploy_token enable :destroy_deploy_token
enable :read_deploy_token enable :read_deploy_token
enable :create_deploy_token
end end
rule { owner }.policy do rule { owner }.policy do
......
...@@ -7,8 +7,13 @@ module Projects ...@@ -7,8 +7,13 @@ module Projects
class LfsDownloadLinkListService < BaseService class LfsDownloadLinkListService < BaseService
DOWNLOAD_ACTION = 'download' DOWNLOAD_ACTION = 'download'
# This could be different per server, but it seems like a reasonable value to start with.
# https://github.com/git-lfs/git-lfs/issues/419
REQUEST_BATCH_SIZE = 100
DownloadLinksError = Class.new(StandardError) DownloadLinksError = Class.new(StandardError)
DownloadLinkNotFound = Class.new(StandardError) DownloadLinkNotFound = Class.new(StandardError)
DownloadLinksRequestEntityTooLargeError = Class.new(StandardError)
attr_reader :remote_uri attr_reader :remote_uri
...@@ -25,16 +30,39 @@ module Projects ...@@ -25,16 +30,39 @@ module Projects
def execute(oids) def execute(oids)
return [] unless project&.lfs_enabled? && remote_uri && oids.present? return [] unless project&.lfs_enabled? && remote_uri && oids.present?
get_download_links(oids) get_download_links_in_batches(oids)
end end
private private
def get_download_links_in_batches(oids, batch_size = REQUEST_BATCH_SIZE)
download_links = []
oids.each_slice(batch_size) do |batch|
download_links += get_download_links(batch)
end
download_links
rescue DownloadLinksRequestEntityTooLargeError => e
# Log this exceptions to see how open it happens
Gitlab::ErrorTracking
.track_exception(e, project_id: project&.id, batch_size: batch_size, oids_count: oids.count)
# Try again with a smaller batch
batch_size /= 2
retry if batch_size > REQUEST_BATCH_SIZE / 3
raise DownloadLinksError, 'Unable to download due to RequestEntityTooLarge errors'
end
def get_download_links(oids) def get_download_links(oids)
response = Gitlab::HTTP.post(remote_uri, response = Gitlab::HTTP.post(remote_uri,
body: request_body(oids), body: request_body(oids),
headers: headers) headers: headers)
raise DownloadLinksRequestEntityTooLargeError if response.request_entity_too_large?
raise DownloadLinksError, response.message unless response.success? raise DownloadLinksError, response.message unless response.success?
# Since the LFS Batch API may return a Content-Ttpe of # Since the LFS Batch API may return a Content-Ttpe of
......
---
title: Optimize services usage counters using batch counters
merge_request: 26973
author:
type: performance
---
title: Fix embeds so that a chart appears only once
merge_request: 26997
author:
type: fixed
---
title: Add api endpoint for creating group deploy tokens
merge_request: 25629
author:
type: added
---
title: Fix issues with non-ASCII plain text files being incorrectly uploaded as binary
in the Web IDE
merge_request: 26360
author:
type: fixed
---
title: Batch processing LFS objects downloads
merge_request: 26434
author:
type: changed
---
title: Add edit custom metric link to metrics dashboard
merge_request: 26511
author:
type: changed
---
title: Add airgap support to Dependency Scanning template
merge_request: 26145
author:
type: changed
...@@ -68,7 +68,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do ...@@ -68,7 +68,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end end
namespace :settings do namespace :settings do
get :members, to: redirect("%{namespace_id}/%{project_id}/project_members") get :members, to: redirect("%{namespace_id}/%{project_id}/-/project_members")
resource :ci_cd, only: [:show, :update], controller: 'ci_cd' do resource :ci_cd, only: [:show, :update], controller: 'ci_cd' do
post :reset_cache post :reset_cache
......
...@@ -156,6 +156,45 @@ Example response: ...@@ -156,6 +156,45 @@ Example response:
] ]
``` ```
### Create a group deploy token
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/21811) in GitLab 12.9.
Creates a new deploy token for a group.
```
POST /groups/:id/deploy_tokens
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer/string | yes | The ID or [URL-encoded path of the group](README.md#namespaced-path-encoding) owned by the authenticated user |
| `name` | string | yes | New deploy token's name |
| `expires_at` | datetime | no | Expiration date for the deploy token. Does not expire if no value is provided. |
| `username` | string | no | Username for deploy token. Default is `gitlab+deploy-token-{n}` |
| `scopes` | array of strings | yes | Indicates the deploy token scopes. Must be at least one of `read_repository` or `read_registry`. |
Example request:
```shell
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" --header "Content-Type: application/json" --data '{"name": "My deploy token", "expires_at": "2021-01-01", "username": "custom-user", "scopes": ["read_repository"]}' "https://gitlab.example.com/api/v4/groups/5/deploy_tokens/"
```
Example response:
```json
{
"id": 1,
"name": "My deploy token",
"username": "custom-user",
"expires_at": "2021-01-01T00:00:00.000Z",
"token": "jMRvtPNxrn3crTAGukpZ",
"scopes": [
"read_registry"
]
}
```
### Delete a group deploy token ### Delete a group deploy token
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/21811) in GitLab 12.9. > [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/21811) in GitLab 12.9.
......
...@@ -18,7 +18,7 @@ a database schema. ...@@ -18,7 +18,7 @@ a database schema.
Adding a `:migration` tag to a test signature enables some custom RSpec Adding a `:migration` tag to a test signature enables some custom RSpec
`before` and `after` hooks in our `before` and `after` hooks in our
[`spec_helper.rb`](https://gitlab.com/gitlab-org/gitlab/blob/3b29908a64ff729c0cf6d93452fe00ab23079c75/spec%2Fspec_helper.rb#L259) [`spec/support/migration.rb`](https://gitlab.com/gitlab-org/gitlab/-/blob/f81fa6ab1dd788b70ef44b85aaba1f31ffafae7d/spec/support/migration.rb)
to run. to run.
A `before` hook will revert all migrations to the point that a migration A `before` hook will revert all migrations to the point that a migration
...@@ -112,7 +112,7 @@ migration. You can find the complete spec in ...@@ -112,7 +112,7 @@ migration. You can find the complete spec in
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20170526185842_migrate_pipeline_stages.rb') require Rails.root.join('db', 'post_migrate', '20170526185842_migrate_pipeline_stages.rb')
describe MigratePipelineStages, :migration do describe MigratePipelineStages do
# Create test data - pipeline and CI/CD jobs. # Create test data - pipeline and CI/CD jobs.
let(:jobs) { table(:ci_builds) } let(:jobs) { table(:ci_builds) }
let(:stages) { table(:ci_stages) } let(:stages) { table(:ci_stages) }
...@@ -163,7 +163,7 @@ schema tag to a context that you want to switch the database schema within. ...@@ -163,7 +163,7 @@ schema tag to a context that you want to switch the database schema within.
Example: Example:
```ruby ```ruby
describe SomeClass, :migration, schema: 20170608152748 do describe SomeClass, schema: 20170608152748 do
# ... # ...
end end
``` ```
...@@ -178,7 +178,7 @@ background migration. You can find the complete spec on ...@@ -178,7 +178,7 @@ background migration. You can find the complete spec on
```ruby ```ruby
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::ArchiveLegacyTraces, :migration, schema: 20180529152628 do describe Gitlab::BackgroundMigration::ArchiveLegacyTraces, schema: 20180529152628 do
include TraceHelpers include TraceHelpers
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
......
...@@ -183,7 +183,7 @@ NOTE: **Note:** GitLab is unable to provide support for IdPs that are not listed ...@@ -183,7 +183,7 @@ NOTE: **Note:** GitLab is unable to provide support for IdPs that are not listed
| JumpCloud | [Single Sign On (SSO) with GitLab](https://support.jumpcloud.com/support/s/article/single-sign-on-sso-with-gitlab-2019-08-21-10-36-47) | | JumpCloud | [Single Sign On (SSO) with GitLab](https://support.jumpcloud.com/support/s/article/single-sign-on-sso-with-gitlab-2019-08-21-10-36-47) |
| Okta | [Setting up a SAML application in Okta](https://developer.okta.com/docs/guides/saml-application-setup/overview/) | | Okta | [Setting up a SAML application in Okta](https://developer.okta.com/docs/guides/saml-application-setup/overview/) |
| OneLogin | [Use the OneLogin SAML Test Connector](https://onelogin.service-now.com/support?id=kb_article&sys_id=93f95543db109700d5505eea4b96198f) | | OneLogin | [Use the OneLogin SAML Test Connector](https://onelogin.service-now.com/support?id=kb_article&sys_id=93f95543db109700d5505eea4b96198f) |
| Ping Identity | [Add and configure a new SAML application](https://support.pingidentity.com/s/document-item?bundleId=pingone&topicId=xsh1564020480660-1.html) | | Ping One for Enterprise | [Add and configure a new SAML application](https://support.pingidentity.com/s/document-item?bundleId=pingone&topicId=xsh1564020480660-1.html) |
When [configuring your identify provider](#configuring-your-identity-provider), please consider the notes below for specific providers to help avoid common issues and as a guide for terminology used. When [configuring your identify provider](#configuring-your-identity-provider), please consider the notes below for specific providers to help avoid common issues and as a guide for terminology used.
......
...@@ -31,7 +31,7 @@ module API ...@@ -31,7 +31,7 @@ module API
end end
params do params do
requires :id, type: Integer, desc: 'The ID of a project' requires :id, type: String, desc: 'The ID of a project'
end end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before do before do
...@@ -74,7 +74,7 @@ module API ...@@ -74,7 +74,7 @@ module API
end end
params do params do
requires :id, type: Integer, desc: 'The ID of a group' requires :id, type: String, desc: 'The ID of a group'
end end
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before do before do
...@@ -94,6 +94,27 @@ module API ...@@ -94,6 +94,27 @@ module API
present paginate(user_group.deploy_tokens), with: Entities::DeployToken present paginate(user_group.deploy_tokens), with: Entities::DeployToken
end end
params do
requires :name, type: String, desc: 'The name of the deploy token'
requires :expires_at, type: DateTime, desc: 'Expiration date for the deploy token. Does not expire if no value is provided.'
requires :username, type: String, desc: 'Username for deploy token. Default is `gitlab+deploy-token-{n}`'
requires :scopes, type: Array[String], values: ::DeployToken::AVAILABLE_SCOPES.map(&:to_s),
desc: 'Indicates the deploy token scopes. Must be at least one of "read_repository" or "read_registry".'
end
desc 'Create a group deploy token' do
detail 'This feature was introduced in GitLab 12.9'
success Entities::DeployTokenWithToken
end
post ':id/deploy_tokens' do
authorize!(:create_deploy_token, user_group)
deploy_token = ::Groups::DeployTokens::CreateService.new(
user_group, current_user, scope_params.merge(declared(params, include_missing: false, include_parent_namespaces: false))
).execute
present deploy_token, with: Entities::DeployTokenWithToken
end
desc 'Delete a group deploy token' do desc 'Delete a group deploy token' do
detail 'This feature was introduced in GitLab 12.9' detail 'This feature was introduced in GitLab 12.9'
end end
......
...@@ -6,7 +6,6 @@ module Banzai ...@@ -6,7 +6,6 @@ module Banzai
# a given link format. To transform references to DB # a given link format. To transform references to DB
# resources in place, prefer to inherit from AbstractReferenceFilter. # resources in place, prefer to inherit from AbstractReferenceFilter.
class InlineEmbedsFilter < HTML::Pipeline::Filter class InlineEmbedsFilter < HTML::Pipeline::Filter
include Gitlab::Utils::StrongMemoize
# Find every relevant link, create a new node based on # Find every relevant link, create a new node based on
# the link, and insert this node after any html content # the link, and insert this node after any html content
# surrounding the link. # surrounding the link.
...@@ -74,9 +73,7 @@ module Banzai ...@@ -74,9 +73,7 @@ module Banzai
# Ex) 'https://<root>/<project>/<environment>/metrics?title=Title&group=Group' # Ex) 'https://<root>/<project>/<environment>/metrics?title=Title&group=Group'
# --> { title: 'Title', group: 'Group' } # --> { title: 'Title', group: 'Group' }
def query_params(url) def query_params(url)
strong_memoize(:query_params) do Gitlab::Metrics::Dashboard::Url.parse_query(url)
Gitlab::Metrics::Dashboard::Url.parse_query(url)
end
end end
# Implement in child class. # Implement in child class.
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
# How to set: https://docs.gitlab.com/ee/ci/yaml/#variables # How to set: https://docs.gitlab.com/ee/ci/yaml/#variables
variables: variables:
DS_ANALYZER_IMAGE_PREFIX: "registry.gitlab.com/gitlab-org/security-products/analyzers" SECURITY_SCANNER_IMAGE_PREFIX: "registry.gitlab.com/gitlab-org/security-products"
DS_ANALYZER_IMAGE_PREFIX: "$SECURITY_SCANNER_IMAGE_PREFIX/analyzers"
DS_DEFAULT_ANALYZERS: "bundler-audit, retire.js, gemnasium, gemnasium-maven, gemnasium-python" DS_DEFAULT_ANALYZERS: "bundler-audit, retire.js, gemnasium, gemnasium-maven, gemnasium-python"
DS_MAJOR_VERSION: 2 DS_MAJOR_VERSION: 2
DS_DISABLE_DIND: "false" DS_DISABLE_DIND: "false"
...@@ -64,7 +65,7 @@ dependency_scanning: ...@@ -64,7 +65,7 @@ dependency_scanning:
) \ ) \
--volume "$PWD:/code" \ --volume "$PWD:/code" \
--volume /var/run/docker.sock:/var/run/docker.sock \ --volume /var/run/docker.sock:/var/run/docker.sock \
"registry.gitlab.com/gitlab-org/security-products/dependency-scanning:$DS_VERSION" /code "$SECURITY_SCANNER_IMAGE_PREFIX/dependency-scanning:$DS_VERSION" /code
artifacts: artifacts:
reports: reports:
dependency_scanning: gl-dependency-scanning-report.json dependency_scanning: gl-dependency-scanning-report.json
......
...@@ -183,10 +183,8 @@ module Gitlab ...@@ -183,10 +183,8 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def services_usage def services_usage
service_counts = count(Service.active.where(template: false).where.not(type: 'JiraService').group(:type), fallback: Hash.new(-1), batch: false) results = Service.available_services_names.without('jira').each_with_object({}) do |service_name, response|
response["projects_#{service_name}_active".to_sym] = count(Service.active.where(template: false, type: "#{service_name}_service".camelize))
results = Service.available_services_names.each_with_object({}) do |service_name, response|
response["projects_#{service_name}_active".to_sym] = service_counts["#{service_name}_service".camelize] || 0
end end
# Keep old Slack keys for backward compatibility, https://gitlab.com/gitlab-data/analytics/issues/3241 # Keep old Slack keys for backward compatibility, https://gitlab.com/gitlab-data/analytics/issues/3241
......
...@@ -12507,7 +12507,9 @@ msgid "Metrics|Duplicating..." ...@@ -12507,7 +12507,9 @@ msgid "Metrics|Duplicating..."
msgstr "" msgstr ""
msgid "Metrics|Edit metric" msgid "Metrics|Edit metric"
msgstr "" msgid_plural "Metrics|Edit metrics"
msgstr[0] ""
msgstr[1] ""
msgid "Metrics|Environment" msgid "Metrics|Environment"
msgstr "" msgstr ""
......
...@@ -62,6 +62,29 @@ describe 'Metrics rendering', :js, :use_clean_rails_memory_store_caching, :sidek ...@@ -62,6 +62,29 @@ describe 'Metrics rendering', :js, :use_clean_rails_memory_store_caching, :sidek
expect(page).to have_text(chart_params[:title]) expect(page).to have_text(chart_params[:title])
expect(page).to have_text(chart_params[:y_label]) expect(page).to have_text(chart_params[:y_label])
end end
context 'when two dashboard urls are included' do
let(:chart_params_2) do
{
group: 'System metrics (Kubernetes)',
title: 'Core Usage (Total)',
y_label: 'Total Cores'
}
end
let(:metrics_url_2) { urls.metrics_project_environment_url(project, environment, **chart_params_2) }
let(:description) { "See [metrics dashboard](#{metrics_url}) for info. \n See [metrics dashboard](#{metrics_url_2}) for info." }
let(:issue) { create(:issue, project: project, description: description) }
it 'shows embedded metrics for both urls' do
visit project_issue_path(project, issue)
expect(page).to have_css('div.prometheus-graph')
expect(page).to have_text(chart_params[:title])
expect(page).to have_text(chart_params[:y_label])
expect(page).to have_text(chart_params_2[:title])
expect(page).to have_text(chart_params_2[:y_label])
end
end
end end
end end
......
...@@ -155,18 +155,17 @@ describe('Issue card component', () => { ...@@ -155,18 +155,17 @@ describe('Issue card component', () => {
describe('assignee default avatar', () => { describe('assignee default avatar', () => {
beforeEach(done => { beforeEach(done => {
global.gon.default_avatar_url = 'default_avatar';
wrapper.setProps({ wrapper.setProps({
issue: { issue: {
...wrapper.props('issue'), ...wrapper.props('issue'),
assignees: [ assignees: [
new ListAssignee( new ListAssignee({
{ id: 1,
id: 1, name: 'testing 123',
name: 'testing 123', username: 'test',
username: 'test', }),
},
'default_avatar',
),
], ],
}, },
}); });
...@@ -174,6 +173,10 @@ describe('Issue card component', () => { ...@@ -174,6 +173,10 @@ describe('Issue card component', () => {
wrapper.vm.$nextTick(done); wrapper.vm.$nextTick(done);
}); });
afterEach(() => {
global.gon.default_avatar_url = null;
});
it('displays defaults avatar if users avatar is null', () => { it('displays defaults avatar if users avatar is null', () => {
expect(wrapper.find('.board-card-assignee img').exists()).toBe(true); expect(wrapper.find('.board-card-assignee img').exists()).toBe(true);
expect(wrapper.find('.board-card-assignee img').attributes('src')).toBe( expect(wrapper.find('.board-card-assignee img').attributes('src')).toBe(
......
import { commitItemIconMap } from '~/ide/constants'; import { commitItemIconMap } from '~/ide/constants';
import { getCommitIconMap } from '~/ide/utils'; import { getCommitIconMap, isTextFile } from '~/ide/utils';
import { decorateData } from '~/ide/stores/utils'; import { decorateData } from '~/ide/stores/utils';
describe('WebIDE utils', () => { describe('WebIDE utils', () => {
describe('isTextFile', () => {
it('returns false for known binary types', () => {
expect(isTextFile('file content', 'image/png', 'my.png')).toBeFalsy();
// mime types are case insensitive
expect(isTextFile('file content', 'IMAGE/PNG', 'my.png')).toBeFalsy();
});
it('returns true for known text types', () => {
expect(isTextFile('file content', 'text/plain', 'my.txt')).toBeTruthy();
// mime types are case insensitive
expect(isTextFile('file content', 'TEXT/PLAIN', 'my.txt')).toBeTruthy();
});
it('returns true for file extensions that Monaco supports syntax highlighting for', () => {
// test based on both MIME and extension
expect(isTextFile('{"éêė":"value"}', 'application/json', 'my.json')).toBeTruthy();
expect(isTextFile('{"éêė":"value"}', 'application/json', '.tsconfig')).toBeTruthy();
expect(isTextFile('SELECT "éêė" from tablename', 'application/sql', 'my.sql')).toBeTruthy();
});
it('returns true even irrespective of whether the mimes, extensions or file names are lowercase or upper case', () => {
expect(isTextFile('{"éêė":"value"}', 'application/json', 'MY.JSON')).toBeTruthy();
expect(isTextFile('SELECT "éêė" from tablename', 'application/sql', 'MY.SQL')).toBeTruthy();
expect(
isTextFile('var code = "something"', 'application/javascript', 'Gruntfile'),
).toBeTruthy();
expect(
isTextFile(
'MAINTAINER Александр "alexander11354322283@me.com"',
'application/octet-stream',
'dockerfile',
),
).toBeTruthy();
});
it('returns false if filename is same as the expected extension', () => {
expect(isTextFile('SELECT "éêė" from tablename', 'application/sql', 'sql')).toBeFalsy();
});
it('returns true for ASCII only content for unknown types', () => {
expect(isTextFile('plain text', 'application/x-new-type', 'hello.mytype')).toBeTruthy();
});
it('returns true for relevant filenames', () => {
expect(
isTextFile(
'MAINTAINER Александр "alexander11354322283@me.com"',
'application/octet-stream',
'Dockerfile',
),
).toBeTruthy();
});
it('returns false for non-ASCII content for unknown types', () => {
expect(isTextFile('{"éêė":"value"}', 'application/octet-stream', 'my.random')).toBeFalsy();
});
});
const createFile = (name = 'name', id = name, type = '', parent = null) => const createFile = (name = 'name', id = name, type = '', parent = null) =>
decorateData({ decorateData({
id, id,
......
...@@ -148,6 +148,82 @@ describe('Panel Type component', () => { ...@@ -148,6 +148,82 @@ describe('Panel Type component', () => {
}); });
}); });
describe('Edit custom metric dropdown item', () => {
const findEditCustomMetricLink = () => wrapper.find({ ref: 'editMetricLink' });
beforeEach(() => {
createWrapper({
graphData: {
...graphDataPrometheusQueryRange,
},
});
return wrapper.vm.$nextTick();
});
it('is not present if the panel is not a custom metric', () => {
expect(findEditCustomMetricLink().exists()).toBe(false);
});
it('is present when the panel contains an edit_path property', () => {
wrapper.setProps({
graphData: {
...graphDataPrometheusQueryRange,
metrics: [
{
...graphDataPrometheusQueryRange.metrics[0],
edit_path: '/root/kubernetes-gke-project/prometheus/metrics/23/edit',
},
],
},
});
return wrapper.vm.$nextTick(() => {
expect(findEditCustomMetricLink().exists()).toBe(true);
});
});
it('shows an "Edit metric" link for a panel with a single metric', () => {
wrapper.setProps({
graphData: {
...graphDataPrometheusQueryRange,
metrics: [
{
...graphDataPrometheusQueryRange.metrics[0],
edit_path: '/root/kubernetes-gke-project/prometheus/metrics/23/edit',
},
],
},
});
return wrapper.vm.$nextTick(() => {
expect(findEditCustomMetricLink().text()).toBe('Edit metric');
});
});
it('shows an "Edit metrics" link for a panel with multiple metrics', () => {
wrapper.setProps({
graphData: {
...graphDataPrometheusQueryRange,
metrics: [
{
...graphDataPrometheusQueryRange.metrics[0],
edit_path: '/root/kubernetes-gke-project/prometheus/metrics/23/edit',
},
{
...graphDataPrometheusQueryRange.metrics[0],
edit_path: '/root/kubernetes-gke-project/prometheus/metrics/23/edit',
},
],
},
});
return wrapper.vm.$nextTick(() => {
expect(findEditCustomMetricLink().text()).toBe('Edit metrics');
});
});
});
describe('View Logs dropdown item', () => { describe('View Logs dropdown item', () => {
const mockLogsPath = '/path/to/logs'; const mockLogsPath = '/path/to/logs';
const mockTimeRange = { duration: { seconds: 120 } }; const mockTimeRange = { duration: { seconds: 120 } };
......
/* eslint-disable no-new */ /* eslint-disable no-new */
import _ from 'underscore'; import { clone } from 'lodash';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import Sidebar from '~/right_sidebar'; import Sidebar from '~/right_sidebar';
...@@ -24,13 +24,13 @@ describe('Issuable right sidebar collapsed todo toggle', () => { ...@@ -24,13 +24,13 @@ describe('Issuable right sidebar collapsed todo toggle', () => {
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
mock.onPost(`${gl.TEST_HOST}/frontend-fixtures/issues-project/todos`).reply(() => { mock.onPost(`${gl.TEST_HOST}/frontend-fixtures/issues-project/todos`).reply(() => {
const response = _.clone(todoData); const response = clone(todoData);
return [200, response]; return [200, response];
}); });
mock.onDelete(/(.*)\/dashboard\/todos\/\d+$/).reply(() => { mock.onDelete(/(.*)\/dashboard\/todos\/\d+$/).reply(() => {
const response = _.clone(todoData); const response = clone(todoData);
delete response.delete_path; delete response.delete_path;
return [200, response]; return [200, response];
......
import _ from 'underscore'; import { range as rge } from 'lodash';
import DirtySubmitForm from '~/dirty_submit/dirty_submit_form'; import DirtySubmitForm from '~/dirty_submit/dirty_submit_form';
import { getInputValue, setInputValue, createForm } from './helper'; import { getInputValue, setInputValue, createForm } from './helper';
...@@ -82,7 +82,7 @@ describe('DirtySubmitForm', () => { ...@@ -82,7 +82,7 @@ describe('DirtySubmitForm', () => {
const { form, input } = createForm(); const { form, input } = createForm();
const updateDirtyInputSpy = spyOn(new DirtySubmitForm(form), 'updateDirtyInput'); const updateDirtyInputSpy = spyOn(new DirtySubmitForm(form), 'updateDirtyInput');
_.range(10).forEach(i => { rge(10).forEach(i => {
setInputValue(input, `change ${i}`, false); setInputValue(input, `change ${i}`, false);
}); });
...@@ -93,7 +93,7 @@ describe('DirtySubmitForm', () => { ...@@ -93,7 +93,7 @@ describe('DirtySubmitForm', () => {
it('does not throttle updates when rapid changes are made to different form elements', () => { it('does not throttle updates when rapid changes are made to different form elements', () => {
const form = document.createElement('form'); const form = document.createElement('form');
const range = _.range(10); const range = rge(10);
range.forEach(i => { range.forEach(i => {
form.innerHTML += `<input type="text" name="input-${i}" class="js-input-${i}"/>`; form.innerHTML += `<input type="text" name="input-${i}" class="js-input-${i}"/>`;
}); });
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import $ from 'jquery'; import $ from 'jquery';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import _ from 'underscore'; import { shuffle } from 'lodash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import IssuableContext from '~/issuable_context'; import IssuableContext from '~/issuable_context';
import LabelsSelect from '~/labels_select'; import LabelsSelect from '~/labels_select';
...@@ -27,7 +27,7 @@ function testLabelClicks(labelOrder, done) { ...@@ -27,7 +27,7 @@ function testLabelClicks(labelOrder, done) {
expect(labelsInDropdown.length).toBe(10); expect(labelsInDropdown.length).toBe(10);
const arrayOfLabels = labelsInDropdown.get(); const arrayOfLabels = labelsInDropdown.get();
const randomArrayOfLabels = _.shuffle(arrayOfLabels); const randomArrayOfLabels = shuffle(arrayOfLabels);
randomArrayOfLabels.forEach((label, i) => { randomArrayOfLabels.forEach((label, i) => {
if (i < saveLabelCount) { if (i < saveLabelCount) {
$(label).click(); $(label).click();
......
import _ from 'underscore'; import { range as rge } from 'lodash';
import Vue from 'vue'; import Vue from 'vue';
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
import app from '~/releases/components/app_index.vue'; import app from '~/releases/components/app_index.vue';
...@@ -28,7 +28,7 @@ describe('Releases App ', () => { ...@@ -28,7 +28,7 @@ describe('Releases App ', () => {
beforeEach(() => { beforeEach(() => {
store = createStore({ modules: { list: listModule } }); store = createStore({ modules: { list: listModule } });
releasesPagination = _.range(21).map(index => ({ releasesPagination = rge(21).map(index => ({
...convertObjectPropsToCamelCase(release, { deep: true }), ...convertObjectPropsToCamelCase(release, { deep: true }),
tagName: `${index}.00`, tagName: `${index}.00`,
})); }));
......
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import { assignIn } from 'lodash';
import waitForPromises from 'spec/helpers/wait_for_promises'; import waitForPromises from 'spec/helpers/wait_for_promises';
import SmartInterval from '~/smart_interval'; import SmartInterval from '~/smart_interval';
...@@ -21,7 +21,7 @@ describe('SmartInterval', function() { ...@@ -21,7 +21,7 @@ describe('SmartInterval', function() {
}; };
if (config) { if (config) {
_.extend(defaultParams, config); assignIn(defaultParams, config);
} }
return new SmartInterval(defaultParams); return new SmartInterval(defaultParams);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::AddMergeRequestDiffCommitsCount, :migration, schema: 20180105212544 do describe Gitlab::BackgroundMigration::AddMergeRequestDiffCommitsCount, schema: 20180105212544 do
let(:projects_table) { table(:projects) } let(:projects_table) { table(:projects) }
let(:merge_requests_table) { table(:merge_requests) } let(:merge_requests_table) { table(:merge_requests) }
let(:merge_request_diffs_table) { table(:merge_request_diffs) } let(:merge_request_diffs_table) { table(:merge_request_diffs) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::ArchiveLegacyTraces, :migration, schema: 20180529152628 do describe Gitlab::BackgroundMigration::ArchiveLegacyTraces, schema: 20180529152628 do
include TraceHelpers include TraceHelpers
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::BackfillHashedProjectRepositories, :migration, schema: 20181130102132 do describe Gitlab::BackgroundMigration::BackfillHashedProjectRepositories, schema: 20181130102132 do
it_behaves_like 'backfill migration for project repositories', :hashed it_behaves_like 'backfill migration for project repositories', :hashed
end end
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::BackfillLegacyProjectRepositories, :migration, schema: 20181212171634 do describe Gitlab::BackgroundMigration::BackfillLegacyProjectRepositories, schema: 20181212171634 do
it_behaves_like 'backfill migration for project repositories', :legacy it_behaves_like 'backfill migration for project repositories', :legacy
end end
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::BackfillProjectFullpathInRepoConfig, :migration, schema: 20181010133639 do describe Gitlab::BackgroundMigration::BackfillProjectFullpathInRepoConfig, schema: 20181010133639 do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:group) { namespaces.create!(name: 'foo', path: 'foo') } let(:group) { namespaces.create!(name: 'foo', path: 'foo') }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
# rubocop:disable RSpec/FactoriesInMigrationSpecs # rubocop:disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::BackfillProjectRepositories do describe Gitlab::BackgroundMigration::BackfillProjectRepositories, schema: :latest do
let(:group) { create(:group, name: 'foo', path: 'foo') } let(:group) { create(:group, name: 'foo', path: 'foo') }
describe described_class::ShardFinder do describe described_class::ShardFinder do
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::BackfillProjectSettings, :migration, schema: 20200114113341 do describe Gitlab::BackgroundMigration::BackfillProjectSettings, schema: 20200114113341 do
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:project_settings) { table(:project_settings) } let(:project_settings) { table(:project_settings) }
let(:namespace) { table(:namespaces).create(name: 'user', path: 'user') } let(:namespace) { table(:namespaces).create(name: 'user', path: 'user') }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::DigestColumn, :migration, schema: 20180913142237 do describe Gitlab::BackgroundMigration::DigestColumn, schema: 20180913142237 do
let(:personal_access_tokens) { table(:personal_access_tokens) } let(:personal_access_tokens) { table(:personal_access_tokens) }
let(:users) { table(:users) } let(:users) { table(:users) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::EncryptColumns, :migration, schema: 20180910115836 do describe Gitlab::BackgroundMigration::EncryptColumns, schema: 20180910115836 do
let(:model) { Gitlab::BackgroundMigration::Models::EncryptColumns::WebHook } let(:model) { Gitlab::BackgroundMigration::Models::EncryptColumns::WebHook }
let(:web_hooks) { table(:web_hooks) } let(:web_hooks) { table(:web_hooks) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::EncryptRunnersTokens, :migration, schema: 20181121111200 do describe Gitlab::BackgroundMigration::EncryptRunnersTokens, schema: 20181121111200 do
let(:settings) { table(:application_settings) } let(:settings) { table(:application_settings) }
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::FixCrossProjectLabelLinks, :migration, schema: 20180702120647 do describe Gitlab::BackgroundMigration::FixCrossProjectLabelLinks, schema: 20180702120647 do
let(:namespaces_table) { table(:namespaces) } let(:namespaces_table) { table(:namespaces) }
let(:projects_table) { table(:projects) } let(:projects_table) { table(:projects) }
let(:issues_table) { table(:issues) } let(:issues_table) { table(:issues) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::FixProjectsWithoutProjectFeature, :migration, schema: 2020_01_27_111840 do describe Gitlab::BackgroundMigration::FixProjectsWithoutProjectFeature, schema: 2020_01_27_111840 do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:project_features) { table(:project_features) } let(:project_features) { table(:project_features) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::FixPromotedEpicsDiscussionIds, :migration, schema: 20190715193142 do describe Gitlab::BackgroundMigration::FixPromotedEpicsDiscussionIds, schema: 20190715193142 do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:users) { table(:users) } let(:users) { table(:users) }
let(:epics) { table(:epics) } let(:epics) { table(:epics) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::FixUserNamespaceNames, :migration, schema: 20190620112608 do describe Gitlab::BackgroundMigration::FixUserNamespaceNames, schema: 20190620112608 do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:users) { table(:users) } let(:users) { table(:users) }
let(:user) { users.create(name: "The user's full name", projects_limit: 10, username: 'not-null', email: '1') } let(:user) { users.create(name: "The user's full name", projects_limit: 10, username: 'not-null', email: '1') }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::FixUserProjectRouteNames, :migration, schema: 20190620112608 do describe Gitlab::BackgroundMigration::FixUserProjectRouteNames, schema: 20190620112608 do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:users) { table(:users) } let(:users) { table(:users) }
let(:routes) { table(:routes) } let(:routes) { table(:routes) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
# rubocop: disable RSpec/FactoriesInMigrationSpecs # rubocop: disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::LegacyUploadMover do describe Gitlab::BackgroundMigration::LegacyUploadMover, schema: :latest do
let(:test_dir) { FileUploader.options['storage_path'] } let(:test_dir) { FileUploader.options['storage_path'] }
let(:filename) { 'image.png' } let(:filename) { 'image.png' }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
# rubocop: disable RSpec/FactoriesInMigrationSpecs # rubocop: disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::LegacyUploadsMigrator do describe Gitlab::BackgroundMigration::LegacyUploadsMigrator, schema: :latest do
let(:test_dir) { FileUploader.options['storage_path'] } let(:test_dir) { FileUploader.options['storage_path'] }
let!(:hashed_project) { create(:project) } let!(:hashed_project) { create(:project) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::MergeRequestAssigneesMigrationProgressCheck do describe Gitlab::BackgroundMigration::MergeRequestAssigneesMigrationProgressCheck, schema: :latest do
context 'rescheduling' do context 'rescheduling' do
context 'when there are ongoing and no dead jobs' do context 'when there are ongoing and no dead jobs' do
it 'reschedules check' do it 'reschedules check' do
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::MigrateBuildStage, :migration, schema: 20180212101928 do describe Gitlab::BackgroundMigration::MigrateBuildStage, schema: 20180212101928 do
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:pipelines) { table(:ci_pipelines) } let(:pipelines) { table(:ci_pipelines) }
let(:stages) { table(:ci_stages) } let(:stages) { table(:ci_stages) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::MigrateFingerprintSha256WithinKeys, :migration, schema: 20200106071113 do describe Gitlab::BackgroundMigration::MigrateFingerprintSha256WithinKeys, schema: 20200106071113 do
subject(:fingerprint_migrator) { described_class.new } subject(:fingerprint_migrator) { described_class.new }
let(:key_table) { table(:keys) } let(:key_table) { table(:keys) }
......
# frozen_string_literal: true # frozen_string_literal: true
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData, :migration, schema: 20200130145430 do describe Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData, schema: 20200130145430 do
let(:services) { table(:services) } let(:services) { table(:services) }
# we need to define the classes due to encryption # we need to define the classes due to encryption
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::MigrateLegacyArtifacts, :migration, schema: 20180816161409 do describe Gitlab::BackgroundMigration::MigrateLegacyArtifacts, schema: 20180816161409 do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:pipelines) { table(:ci_pipelines) } let(:pipelines) { table(:ci_pipelines) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::MigrateNullPrivateProfileToFalse, :migration, schema: 20190620105427 do describe Gitlab::BackgroundMigration::MigrateNullPrivateProfileToFalse, schema: 20190620105427 do
let(:users) { table(:users) } let(:users) { table(:users) }
it 'correctly migrates nil private_profile to false' do it 'correctly migrates nil private_profile to false' do
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::MigratePagesMetadata, :migration, schema: 20190919040324 do describe Gitlab::BackgroundMigration::MigratePagesMetadata, schema: 20190919040324 do
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
subject(:migrate_pages_metadata) { described_class.new } subject(:migrate_pages_metadata) { described_class.new }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::MigrateStageIndex, :migration, schema: 20180420080616 do describe Gitlab::BackgroundMigration::MigrateStageIndex, schema: 20180420080616 do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:pipelines) { table(:ci_pipelines) } let(:pipelines) { table(:ci_pipelines) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::PopulateClusterKubernetesNamespaceTable, :migration, schema: 20181022173835 do describe Gitlab::BackgroundMigration::PopulateClusterKubernetesNamespaceTable, schema: 20181022173835 do
include MigrationHelpers::ClusterHelpers include MigrationHelpers::ClusterHelpers
let(:migration) { described_class.new } let(:migration) { described_class.new }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::PopulateMergeRequestAssigneesTable, :migration, schema: 20190315191339 do describe Gitlab::BackgroundMigration::PopulateMergeRequestAssigneesTable, schema: 20190315191339 do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:users) { table(:users) } let(:users) { table(:users) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
# Rollback DB to 10.5 (later than this was originally written for) because it still needs to work. # Rollback DB to 10.5 (later than this was originally written for) because it still needs to work.
describe Gitlab::BackgroundMigration::PopulateUntrackedUploadsDependencies::UntrackedFile, :migration, schema: 20180208183958 do describe Gitlab::BackgroundMigration::PopulateUntrackedUploadsDependencies::UntrackedFile, schema: 20180208183958 do
include MigrationsHelpers::TrackUntrackedUploadsHelpers include MigrationsHelpers::TrackUntrackedUploadsHelpers
let!(:appearances) { table(:appearances) } let!(:appearances) { table(:appearances) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
# Rollback DB to 10.5 (later than this was originally written for) because it still needs to work. # Rollback DB to 10.5 (later than this was originally written for) because it still needs to work.
describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :migration, schema: 20180208183958 do describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, schema: 20180208183958 do
include MigrationsHelpers::TrackUntrackedUploadsHelpers include MigrationsHelpers::TrackUntrackedUploadsHelpers
subject { described_class.new } subject { described_class.new }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
# Rollback DB to 10.5 (later than this was originally written for) because it still needs to work. # Rollback DB to 10.5 (later than this was originally written for) because it still needs to work.
describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :migration, schema: 20180208183958 do describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, schema: 20180208183958 do
include MigrationsHelpers::TrackUntrackedUploadsHelpers include MigrationsHelpers::TrackUntrackedUploadsHelpers
let!(:untracked_files_for_uploads) { table(:untracked_files_for_uploads) } let!(:untracked_files_for_uploads) { table(:untracked_files_for_uploads) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::RecalculateProjectAuthorizations, :migration, schema: 20200204113223 do describe Gitlab::BackgroundMigration::RecalculateProjectAuthorizations, schema: 20200204113223 do
let(:users_table) { table(:users) } let(:users_table) { table(:users) }
let(:namespaces_table) { table(:namespaces) } let(:namespaces_table) { table(:namespaces) }
let(:projects_table) { table(:projects) } let(:projects_table) { table(:projects) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::RecalculateProjectAuthorizationsWithMinMaxUserId, :migration, schema: 20200204113224 do describe Gitlab::BackgroundMigration::RecalculateProjectAuthorizationsWithMinMaxUserId, schema: 20200204113224 do
let(:users_table) { table(:users) } let(:users_table) { table(:users) }
let(:min) { 1 } let(:min) { 1 }
let(:max) { 5 } let(:max) { 5 }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::RemoveRestrictedTodos, :migration, schema: 20180704204006 do describe Gitlab::BackgroundMigration::RemoveRestrictedTodos, schema: 20180704204006 do
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:users) { table(:users) } let(:users) { table(:users) }
let(:todos) { table(:todos) } let(:todos) { table(:todos) }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::ResetMergeStatus, :migration, schema: 20190528180441 do describe Gitlab::BackgroundMigration::ResetMergeStatus, schema: 20190528180441 do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190527194900_schedule_calculate_wiki_sizes.rb') require Rails.root.join('db', 'post_migrate', '20190527194900_schedule_calculate_wiki_sizes.rb')
describe ScheduleCalculateWikiSizes, :migration do describe ScheduleCalculateWikiSizes do
let(:migration_class) { Gitlab::BackgroundMigration::CalculateWikiSizes } let(:migration_class) { Gitlab::BackgroundMigration::CalculateWikiSizes }
let(:migration_name) { migration_class.to_s.demodulize } let(:migration_name) { migration_class.to_s.demodulize }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices, :migration, schema: 20180122154930 do describe Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices, schema: 20180122154930 do
let(:services) { table(:services) } let(:services) { table(:services) }
describe '#perform' do describe '#perform' do
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks, :migration, schema: 20180104131052 do describe Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks, schema: 20180104131052 do
let(:web_hooks) { table(:web_hooks) } let(:web_hooks) { table(:web_hooks) }
describe '#perform' do describe '#perform' do
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration::UpdateExistingSubgroupToMatchVisibilityLevelOfParent, :migration, schema: 2020_01_10_121314 do describe Gitlab::BackgroundMigration::UpdateExistingSubgroupToMatchVisibilityLevelOfParent, schema: 2020_01_10_121314 do
include MigrationHelpers::NamespacesHelpers include MigrationHelpers::NamespacesHelpers
context 'private visibility level' do context 'private visibility level' do
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::BackgroundMigration do describe Gitlab::BackgroundMigration, schema: :latest do
describe '.queue' do describe '.queue' do
it 'returns background migration worker queue' do it 'returns background migration worker queue' do
expect(described_class.queue) expect(described_class.queue)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190924152703_migrate_issue_trackers_data.rb') require Rails.root.join('db', 'post_migrate', '20190924152703_migrate_issue_trackers_data.rb')
describe MigrateIssueTrackersData, :migration do describe MigrateIssueTrackersData do
let(:services) { table(:services) } let(:services) { table(:services) }
let(:migration_class) { Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData } let(:migration_class) { Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData }
let(:migration_name) { migration_class.to_s.demodulize } let(:migration_name) { migration_class.to_s.demodulize }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20191015154408_drop_merge_requests_require_code_owner_approval_from_projects.rb') require Rails.root.join('db', 'post_migrate', '20191015154408_drop_merge_requests_require_code_owner_approval_from_projects.rb')
describe DropMergeRequestsRequireCodeOwnerApprovalFromProjects, :migration do describe DropMergeRequestsRequireCodeOwnerApprovalFromProjects do
let(:projects_table) { table(:projects) } let(:projects_table) { table(:projects) }
subject(:migration) { described_class.new } subject(:migration) { described_class.new }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20191125114345_add_admin_mode_protected_path.rb') require Rails.root.join('db', 'migrate', '20191125114345_add_admin_mode_protected_path.rb')
describe AddAdminModeProtectedPath, :migration do describe AddAdminModeProtectedPath do
ADMIN_MODE_ENDPOINT = '/admin/session' ADMIN_MODE_ENDPOINT = '/admin/session'
subject(:migration) { described_class.new } subject(:migration) { described_class.new }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20191204114127_delete_legacy_triggers.rb') require Rails.root.join('db', 'post_migrate', '20191204114127_delete_legacy_triggers.rb')
describe DeleteLegacyTriggers, :migration, schema: 2019_11_25_140458 do describe DeleteLegacyTriggers, schema: 2019_11_25_140458 do
let(:ci_trigger_table) { table(:ci_triggers) } let(:ci_trigger_table) { table(:ci_triggers) }
let(:user) { table(:users).create!(name: 'test', email: 'test@example.com', projects_limit: 1) } let(:user) { table(:users).create!(name: 'test', email: 'test@example.com', projects_limit: 1) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20200107172020_add_timestamp_softwarelicensespolicy.rb') require Rails.root.join('db', 'migrate', '20200107172020_add_timestamp_softwarelicensespolicy.rb')
describe AddTimestampSoftwarelicensespolicy, :migration do describe AddTimestampSoftwarelicensespolicy do
let(:software_licenses_policy) { table(:software_license_policies) } let(:software_licenses_policy) { table(:software_license_policies) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:licenses) { table(:software_licenses) } let(:licenses) { table(:software_licenses) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200122123016_backfill_project_settings.rb') require Rails.root.join('db', 'post_migrate', '20200122123016_backfill_project_settings.rb')
describe BackfillProjectSettings, :migration, :sidekiq, schema: 20200114113341 do describe BackfillProjectSettings, :sidekiq, schema: 20200114113341 do
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:namespace) { table(:namespaces).create(name: 'user', path: 'user') } let(:namespace) { table(:namespaces).create(name: 'user', path: 'user') }
let(:project) { projects.create(namespace_id: namespace.id) } let(:project) { projects.create(namespace_id: namespace.id) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200123155929_remove_invalid_jira_data.rb') require Rails.root.join('db', 'post_migrate', '20200123155929_remove_invalid_jira_data.rb')
describe RemoveInvalidJiraData, :migration do describe RemoveInvalidJiraData do
let(:jira_tracker_data) { table(:jira_tracker_data) } let(:jira_tracker_data) { table(:jira_tracker_data) }
let(:services) { table(:services) } let(:services) { table(:services) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200127090233_remove_invalid_issue_tracker_data.rb') require Rails.root.join('db', 'post_migrate', '20200127090233_remove_invalid_issue_tracker_data.rb')
describe RemoveInvalidIssueTrackerData, :migration do describe RemoveInvalidIssueTrackerData do
let(:issue_tracker_data) { table(:issue_tracker_data) } let(:issue_tracker_data) { table(:issue_tracker_data) }
let(:services) { table(:services) } let(:services) { table(:services) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200130145430_reschedule_migrate_issue_trackers_data.rb') require Rails.root.join('db', 'post_migrate', '20200130145430_reschedule_migrate_issue_trackers_data.rb')
describe RescheduleMigrateIssueTrackersData, :migration do describe RescheduleMigrateIssueTrackersData do
let(:services) { table(:services) } let(:services) { table(:services) }
let(:migration_class) { Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData } let(:migration_class) { Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData }
let(:migration_name) { migration_class.to_s.demodulize } let(:migration_name) { migration_class.to_s.demodulize }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180122154930_schedule_set_confidential_note_events_on_services.rb') require Rails.root.join('db', 'post_migrate', '20180122154930_schedule_set_confidential_note_events_on_services.rb')
describe ScheduleSetConfidentialNoteEventsOnServices, :migration do describe ScheduleSetConfidentialNoteEventsOnServices do
let(:services_table) { table(:services) } let(:services_table) { table(:services) }
let(:migration_class) { Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices } let(:migration_class) { Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices }
let(:migration_name) { migration_class.to_s.demodulize } let(:migration_name) { migration_class.to_s.demodulize }
......
...@@ -5,7 +5,7 @@ require 'spec_helper' ...@@ -5,7 +5,7 @@ require 'spec_helper'
# Check consistency of db/schema.rb version, migrations' timestamps, and the latest migration timestamp # Check consistency of db/schema.rb version, migrations' timestamps, and the latest migration timestamp
# stored in the database's schema_migrations table. # stored in the database's schema_migrations table.
describe ActiveRecord::Schema do describe ActiveRecord::Schema, schema: :latest do
let(:latest_migration_timestamp) do let(:latest_migration_timestamp) do
migrations_paths = %w[db/migrate db/post_migrate] migrations_paths = %w[db/migrate db/post_migrate]
.map { |path| Rails.root.join(*path, '*') } .map { |path| Rails.root.join(*path, '*') }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20191023152913_add_default_and_free_plans.rb') require Rails.root.join('db', 'migrate', '20191023152913_add_default_and_free_plans.rb')
describe AddDefaultAndFreePlans, :migration do describe AddDefaultAndFreePlans do
describe 'migrate' do describe 'migrate' do
let(:plans) { table(:plans) } let(:plans) { table(:plans) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20200122161638_add_deploy_token_type_to_deploy_tokens.rb') require Rails.root.join('db', 'migrate', '20200122161638_add_deploy_token_type_to_deploy_tokens.rb')
describe AddDeployTokenTypeToDeployTokens, :migration do describe AddDeployTokenTypeToDeployTokens do
let(:deploy_tokens) { table(:deploy_tokens) } let(:deploy_tokens) { table(:deploy_tokens) }
let(:deploy_token) do let(:deploy_token) do
deploy_tokens.create(name: 'token_test', deploy_tokens.create(name: 'token_test',
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180710162338_add_foreign_key_from_notification_settings_to_users.rb') require Rails.root.join('db', 'migrate', '20180710162338_add_foreign_key_from_notification_settings_to_users.rb')
describe AddForeignKeyFromNotificationSettingsToUsers, :migration do describe AddForeignKeyFromNotificationSettingsToUsers do
let(:notification_settings) { table(:notification_settings) } let(:notification_settings) { table(:notification_settings) }
let(:users) { table(:users) } let(:users) { table(:users) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180201110056_add_foreign_keys_to_todos.rb') require Rails.root.join('db', 'migrate', '20180201110056_add_foreign_keys_to_todos.rb')
describe AddForeignKeysToTodos, :migration do describe AddForeignKeysToTodos do
let(:todos) { table(:todos) } let(:todos) { table(:todos) }
let(:users) { table(:users) } let(:users) { table(:users) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb') require Rails.root.join('db', 'migrate', '20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb')
describe AddNotNullConstraintToProjectMirrorDataForeignKey, :migration do describe AddNotNullConstraintToProjectMirrorDataForeignKey do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:import_state) { table(:project_mirror_data) } let(:import_state) { table(:project_mirror_data) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180423204600_add_pages_access_level_to_project_feature.rb') require Rails.root.join('db', 'migrate', '20180423204600_add_pages_access_level_to_project_feature.rb')
describe AddPagesAccessLevelToProjectFeature, :migration do describe AddPagesAccessLevelToProjectFeature do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:features) { table(:project_features) } let(:features) { table(:project_features) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180420010016_add_pipeline_build_foreign_key.rb') require Rails.root.join('db', 'migrate', '20180420010016_add_pipeline_build_foreign_key.rb')
describe AddPipelineBuildForeignKey, :migration do describe AddPipelineBuildForeignKey do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:pipelines) { table(:ci_pipelines) } let(:pipelines) { table(:ci_pipelines) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200114112932_add_temporary_partial_index_on_project_id_to_services.rb') require Rails.root.join('db', 'post_migrate', '20200114112932_add_temporary_partial_index_on_project_id_to_services.rb')
describe AddTemporaryPartialIndexOnProjectIdToServices, :migration do describe AddTemporaryPartialIndexOnProjectIdToServices do
let(:migration) { described_class.new } let(:migration) { described_class.new }
describe '#up' do describe '#up' do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190404143330_add_unique_constraint_to_approvals_user_id_and_merge_request_id.rb') require Rails.root.join('db', 'post_migrate', '20190404143330_add_unique_constraint_to_approvals_user_id_and_merge_request_id.rb')
describe AddUniqueConstraintToApprovalsUserIdAndMergeRequestId, :migration do describe AddUniqueConstraintToApprovalsUserIdAndMergeRequestId do
let(:migration) { described_class.new } let(:migration) { described_class.new }
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180511174224_add_unique_constraint_to_project_features_project_id.rb') require Rails.root.join('db', 'post_migrate', '20180511174224_add_unique_constraint_to_project_features_project_id.rb')
describe AddUniqueConstraintToProjectFeaturesProjectId, :migration do describe AddUniqueConstraintToProjectFeaturesProjectId do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:features) { table(:project_features) } let(:features) { table(:project_features) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180425131009_assure_commits_count_for_merge_request_diff.rb') require Rails.root.join('db', 'migrate', '20180425131009_assure_commits_count_for_merge_request_diff.rb')
describe AssureCommitsCountForMergeRequestDiff, :migration, :redis do describe AssureCommitsCountForMergeRequestDiff, :redis do
let(:migration) { spy('migration') } let(:migration) { spy('migration') }
before do before do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20190628185004_backfill_and_add_not_null_constraint_to_released_at_column_on_releases_table.rb') require Rails.root.join('db', 'migrate', '20190628185004_backfill_and_add_not_null_constraint_to_released_at_column_on_releases_table.rb')
describe BackfillAndAddNotNullConstraintToReleasedAtColumnOnReleasesTable, :migration do describe BackfillAndAddNotNullConstraintToReleasedAtColumnOnReleasesTable do
let(:releases) { table(:releases) } let(:releases) { table(:releases) }
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20191213184609_backfill_operations_feature_flags_active.rb') require Rails.root.join('db', 'migrate', '20191213184609_backfill_operations_feature_flags_active.rb')
describe BackfillOperationsFeatureFlagsActive, :migration do describe BackfillOperationsFeatureFlagsActive do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:flags) { table(:operations_feature_flags) } let(:flags) { table(:operations_feature_flags) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200117194850_backfill_operations_feature_flags_iid.rb') require Rails.root.join('db', 'post_migrate', '20200117194850_backfill_operations_feature_flags_iid.rb')
describe BackfillOperationsFeatureFlagsIid, :migration do describe BackfillOperationsFeatureFlagsIid do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:flags) { table(:operations_feature_flags) } let(:flags) { table(:operations_feature_flags) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20181212104941_backfill_releases_name_with_tag_name.rb') require Rails.root.join('db', 'migrate', '20181212104941_backfill_releases_name_with_tag_name.rb')
describe BackfillReleasesNameWithTagName, :migration do describe BackfillReleasesNameWithTagName do
let(:releases) { table(:releases) } let(:releases) { table(:releases) }
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20190920194925_backfill_releases_table_updated_at_and_add_not_null_constraints_to_timestamps.rb') require Rails.root.join('db', 'migrate', '20190920194925_backfill_releases_table_updated_at_and_add_not_null_constraints_to_timestamps.rb')
describe BackfillReleasesTableUpdatedAtAndAddNotNullConstraintsToTimestamps, :migration do describe BackfillReleasesTableUpdatedAtAndAddNotNullConstraintsToTimestamps do
let(:releases) { table(:releases) } let(:releases) { table(:releases) }
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20181010133639_backfill_store_project_full_path_in_repo.rb') require Rails.root.join('db', 'post_migrate', '20181010133639_backfill_store_project_full_path_in_repo.rb')
describe BackfillStoreProjectFullPathInRepo, :migration do describe BackfillStoreProjectFullPathInRepo do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:group) { namespaces.create!(name: 'foo', path: 'foo') } let(:group) { namespaces.create!(name: 'foo', path: 'foo') }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
require Rails.root.join('db', 'migrate', '20190402150158_backport_enterprise_schema.rb') require Rails.root.join('db', 'migrate', '20190402150158_backport_enterprise_schema.rb')
describe BackportEnterpriseSchema, :migration, schema: 20190329085614 do describe BackportEnterpriseSchema, schema: 20190329085614 do
include MigrationsHelpers include MigrationsHelpers
def drop_if_exists(table) def drop_if_exists(table)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180531220618_change_default_value_for_dsa_key_restriction.rb') require Rails.root.join('db', 'migrate', '20180531220618_change_default_value_for_dsa_key_restriction.rb')
describe ChangeDefaultValueForDsaKeyRestriction, :migration do describe ChangeDefaultValueForDsaKeyRestriction do
let(:application_settings) { table(:application_settings) } let(:application_settings) { table(:application_settings) }
before do before do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20190725012225_change_outbound_local_requests_whitelist_default.rb') require Rails.root.join('db', 'migrate', '20190725012225_change_outbound_local_requests_whitelist_default.rb')
describe ChangeOutboundLocalRequestsWhitelistDefault, :migration do describe ChangeOutboundLocalRequestsWhitelistDefault do
let(:application_settings) { table(:application_settings) } let(:application_settings) { table(:application_settings) }
it 'defaults to empty array' do it 'defaults to empty array' do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20190516155724_change_packages_size_defaults_in_project_statistics.rb') require Rails.root.join('db', 'migrate', '20190516155724_change_packages_size_defaults_in_project_statistics.rb')
describe ChangePackagesSizeDefaultsInProjectStatistics, :migration do describe ChangePackagesSizeDefaultsInProjectStatistics do
let(:project_statistics) { table(:project_statistics) } let(:project_statistics) { table(:project_statistics) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20200214085940_clean_grafana_url.rb') require Rails.root.join('db', 'migrate', '20200214085940_clean_grafana_url.rb')
describe CleanGrafanaUrl, :migration do describe CleanGrafanaUrl do
let(:application_settings_table) { table(:application_settings) } let(:application_settings_table) { table(:application_settings) }
[ [
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190313092516_clean_up_noteable_id_for_notes_on_commits.rb') require Rails.root.join('db', 'post_migrate', '20190313092516_clean_up_noteable_id_for_notes_on_commits.rb')
describe CleanUpNoteableIdForNotesOnCommits, :migration do describe CleanUpNoteableIdForNotesOnCommits do
let(:notes) { table(:notes) } let(:notes) { table(:notes) }
before do before do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180420010616_cleanup_build_stage_migration.rb') require Rails.root.join('db', 'migrate', '20180420010616_cleanup_build_stage_migration.rb')
describe CleanupBuildStageMigration, :migration, :redis do describe CleanupBuildStageMigration, :redis do
let(:migration) { spy('migration') } let(:migration) { spy('migration') }
before do before do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20181108091549_cleanup_environments_external_url.rb') require Rails.root.join('db', 'migrate', '20181108091549_cleanup_environments_external_url.rb')
describe CleanupEnvironmentsExternalUrl, :migration do describe CleanupEnvironmentsExternalUrl do
let(:environments) { table(:environments) } let(:environments) { table(:environments) }
let(:invalid_entries) { environments.where(environments.arel_table[:external_url].matches('javascript://%')) } let(:invalid_entries) { environments.where(environments.arel_table[:external_url].matches('javascript://%')) }
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20190104182041_cleanup_legacy_artifact_migration.rb') require Rails.root.join('db', 'migrate', '20190104182041_cleanup_legacy_artifact_migration.rb')
describe CleanupLegacyArtifactMigration, :migration, :redis do describe CleanupLegacyArtifactMigration, :redis do
let(:migration) { spy('migration') } let(:migration) { spy('migration') }
context 'when still legacy artifacts exist' do context 'when still legacy artifacts exist' do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200128210353_cleanup_optimistic_locking_nulls') require Rails.root.join('db', 'post_migrate', '20200128210353_cleanup_optimistic_locking_nulls')
describe CleanupOptimisticLockingNulls, :migration do describe CleanupOptimisticLockingNulls do
TABLES = %w(epics merge_requests issues).freeze TABLES = %w(epics merge_requests issues).freeze
TABLES.each do |table| TABLES.each do |table|
let(table.to_sym) { table(table.to_sym) } let(table.to_sym) { table(table.to_sym) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180604123514_cleanup_stages_position_migration.rb') require Rails.root.join('db', 'post_migrate', '20180604123514_cleanup_stages_position_migration.rb')
describe CleanupStagesPositionMigration, :migration, :redis do describe CleanupStagesPositionMigration, :redis do
let(:migration) { spy('migration') } let(:migration) { spy('migration') }
before do before do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200214214934_create_environment_for_self_monitoring_project') require Rails.root.join('db', 'post_migrate', '20200214214934_create_environment_for_self_monitoring_project')
describe CreateEnvironmentForSelfMonitoringProject, :migration do describe CreateEnvironmentForSelfMonitoringProject do
let(:application_settings_table) { table(:application_settings) } let(:application_settings_table) { table(:application_settings) }
let(:environments) { table(:environments) } let(:environments) { table(:environments) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180413022611_create_missing_namespace_for_internal_users.rb') require Rails.root.join('db', 'migrate', '20180413022611_create_missing_namespace_for_internal_users.rb')
describe CreateMissingNamespaceForInternalUsers, :migration do describe CreateMissingNamespaceForInternalUsers do
let(:users) { table(:users) } let(:users) { table(:users) }
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:routes) { table(:routes) } let(:routes) { table(:routes) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200117194900_delete_internal_ids_where_feature_flags_usage') require Rails.root.join('db', 'post_migrate', '20200117194900_delete_internal_ids_where_feature_flags_usage')
describe DeleteInternalIdsWhereFeatureFlagsUsage, :migration do describe DeleteInternalIdsWhereFeatureFlagsUsage do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:internal_ids) { table(:internal_ids) } let(:internal_ids) { table(:internal_ids) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20200304160801_delete_template_services_duplicated_by_type.rb') require Rails.root.join('db', 'migrate', '20200304160801_delete_template_services_duplicated_by_type.rb')
describe DeleteTemplateServicesDuplicatedByType, :migration do describe DeleteTemplateServicesDuplicatedByType do
let(:services) { table(:services) } let(:services) { table(:services) }
before do before do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20200221144534_drop_activate_prometheus_services_background_jobs.rb') require Rails.root.join('db', 'migrate', '20200221144534_drop_activate_prometheus_services_background_jobs.rb')
describe DropActivatePrometheusServicesBackgroundJobs, :sidekiq, :redis, :migration, schema: 2020_02_21_144534 do describe DropActivatePrometheusServicesBackgroundJobs, :sidekiq, :redis, schema: 2020_02_21_144534 do
subject(:migration) { described_class.new } subject(:migration) { described_class.new }
describe '#up' do describe '#up' do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20200116051619_drop_background_migration_jobs.rb') require Rails.root.join('db', 'migrate', '20200116051619_drop_background_migration_jobs.rb')
describe DropBackgroundMigrationJobs, :sidekiq, :redis, :migration, schema: 2020_01_16_051619 do describe DropBackgroundMigrationJobs, :sidekiq, :redis, schema: 2020_01_16_051619 do
subject(:migration) { described_class.new } subject(:migration) { described_class.new }
describe '#up' do describe '#up' do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180711103851_drop_duplicate_protected_tags.rb') require Rails.root.join('db', 'migrate', '20180711103851_drop_duplicate_protected_tags.rb')
describe DropDuplicateProtectedTags, :migration do describe DropDuplicateProtectedTags do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:protected_tags) { table(:protected_tags) } let(:protected_tags) { table(:protected_tags) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20191128162854_drop_project_ci_cd_settings_merge_trains_enabled.rb') require Rails.root.join('db', 'post_migrate', '20191128162854_drop_project_ci_cd_settings_merge_trains_enabled.rb')
describe DropProjectCiCdSettingsMergeTrainsEnabled, :migration do describe DropProjectCiCdSettingsMergeTrainsEnabled do
let!(:project_ci_cd_setting) { table(:project_ci_cd_settings) } let!(:project_ci_cd_setting) { table(:project_ci_cd_settings) }
it 'correctly migrates up and down' do it 'correctly migrates up and down' do
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190711201818_encrypt_deploy_tokens_tokens.rb') require Rails.root.join('db', 'post_migrate', '20190711201818_encrypt_deploy_tokens_tokens.rb')
describe EncryptDeployTokensTokens, :migration do describe EncryptDeployTokensTokens do
let(:migration) { described_class.new } let(:migration) { described_class.new }
let(:deployment_tokens) { table(:deploy_tokens) } let(:deployment_tokens) { table(:deploy_tokens) }
let(:plaintext) { "secret-token" } let(:plaintext) { "secret-token" }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190606175050_encrypt_feature_flags_clients_tokens.rb') require Rails.root.join('db', 'post_migrate', '20190606175050_encrypt_feature_flags_clients_tokens.rb')
describe EncryptFeatureFlagsClientsTokens, :migration do describe EncryptFeatureFlagsClientsTokens do
let(:migration) { described_class.new } let(:migration) { described_class.new }
let(:feature_flags_clients) { table(:operations_feature_flags_clients) } let(:feature_flags_clients) { table(:operations_feature_flags_clients) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20191120115530_encrypt_plaintext_attributes_on_application_settings.rb') require Rails.root.join('db', 'migrate', '20191120115530_encrypt_plaintext_attributes_on_application_settings.rb')
describe EncryptPlaintextAttributesOnApplicationSettings, :migration do describe EncryptPlaintextAttributesOnApplicationSettings do
let(:migration) { described_class.new } let(:migration) { described_class.new }
let(:application_settings) { table(:application_settings) } let(:application_settings) { table(:application_settings) }
let(:plaintext) { 'secret-token' } let(:plaintext) { 'secret-token' }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190620112608_enqueue_reset_merge_status_second_run.rb') require Rails.root.join('db', 'post_migrate', '20190620112608_enqueue_reset_merge_status_second_run.rb')
describe EnqueueResetMergeStatusSecondRun, :migration do describe EnqueueResetMergeStatusSecondRun do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190528180441_enqueue_reset_merge_status.rb') require Rails.root.join('db', 'post_migrate', '20190528180441_enqueue_reset_merge_status.rb')
describe EnqueueResetMergeStatus, :migration do describe EnqueueResetMergeStatus do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180216121030_enqueue_verify_pages_domain_workers') require Rails.root.join('db', 'post_migrate', '20180216121030_enqueue_verify_pages_domain_workers')
describe EnqueueVerifyPagesDomainWorkers, :migration do describe EnqueueVerifyPagesDomainWorkers do
around do |example| around do |example|
Sidekiq::Testing.fake! do Sidekiq::Testing.fake! do
example.run example.run
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20181030135124_fill_empty_finished_at_in_deployments') require Rails.root.join('db', 'post_migrate', '20181030135124_fill_empty_finished_at_in_deployments')
describe FillEmptyFinishedAtInDeployments, :migration do describe FillEmptyFinishedAtInDeployments do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:environments) { table(:environments) } let(:environments) { table(:environments) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180424151928_fill_file_store') require Rails.root.join('db', 'post_migrate', '20180424151928_fill_file_store')
describe FillFileStore, :migration do describe FillFileStore do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:builds) { table(:ci_builds) } let(:builds) { table(:ci_builds) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20191004081520_fill_productivity_analytics_start_date.rb') require Rails.root.join('db', 'migrate', '20191004081520_fill_productivity_analytics_start_date.rb')
describe FillProductivityAnalyticsStartDate, :migration do describe FillProductivityAnalyticsStartDate do
let(:settings_table) { table('application_settings') } let(:settings_table) { table('application_settings') }
let(:metrics_table) { table('merge_request_metrics') } let(:metrics_table) { table('merge_request_metrics') }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20191213120427_fix_max_pages_size.rb') require Rails.root.join('db', 'migrate', '20191213120427_fix_max_pages_size.rb')
describe FixMaxPagesSize, :migration do describe FixMaxPagesSize do
let(:application_settings) { table(:application_settings) } let(:application_settings) { table(:application_settings) }
let!(:default_setting) { application_settings.create! } let!(:default_setting) { application_settings.create! }
let!(:max_possible_setting) { application_settings.create!(max_pages_size: described_class::MAX_SIZE) } let!(:max_possible_setting) { application_settings.create!(max_pages_size: described_class::MAX_SIZE) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190131122559_fix_null_type_labels') require Rails.root.join('db', 'post_migrate', '20190131122559_fix_null_type_labels')
describe FixNullTypeLabels, :migration do describe FixNullTypeLabels do
let(:migration) { described_class.new } let(:migration) { described_class.new }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20190604184643_fix_pool_repository_source_project_id.rb') require Rails.root.join('db', 'migrate', '20190604184643_fix_pool_repository_source_project_id.rb')
describe FixPoolRepositorySourceProjectId, :migration do describe FixPoolRepositorySourceProjectId do
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:pool_repositories) { table(:pool_repositories) } let(:pool_repositories) { table(:pool_repositories) }
let(:shards) { table(:shards) } let(:shards) { table(:shards) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200127111840_fix_projects_without_project_feature.rb') require Rails.root.join('db', 'post_migrate', '20200127111840_fix_projects_without_project_feature.rb')
describe FixProjectsWithoutProjectFeature, :migration do describe FixProjectsWithoutProjectFeature do
let(:namespace) { table(:namespaces).create(name: 'gitlab', path: 'gitlab-org') } let(:namespace) { table(:namespaces).create(name: 'gitlab', path: 'gitlab-org') }
let!(:projects) do let!(:projects) do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190703185326_fix_wrong_pages_access_level.rb') require Rails.root.join('db', 'post_migrate', '20190703185326_fix_wrong_pages_access_level.rb')
describe FixWrongPagesAccessLevel, :migration, :sidekiq_might_not_need_inline, schema: 20190628185004 do describe FixWrongPagesAccessLevel, :sidekiq_might_not_need_inline, schema: 20190628185004 do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
let(:migration_class) { described_class::MIGRATION } let(:migration_class) { described_class::MIGRATION }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20190524062810_generate_lets_encrypt_private_key.rb') require Rails.root.join('db', 'migrate', '20190524062810_generate_lets_encrypt_private_key.rb')
describe GenerateLetsEncryptPrivateKey, :migration do describe GenerateLetsEncryptPrivateKey do
describe '#up' do describe '#up' do
it 'does not fail' do it 'does not fail' do
expect do expect do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180702134423_generate_missing_routes.rb') require Rails.root.join('db', 'migrate', '20180702134423_generate_missing_routes.rb')
describe GenerateMissingRoutes, :migration do describe GenerateMissingRoutes do
describe '#up' do describe '#up' do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180831164910_import_common_metrics.rb') require Rails.root.join('db', 'migrate', '20180831164910_import_common_metrics.rb')
describe ImportCommonMetrics, :migration do describe ImportCommonMetrics do
describe '#up' do describe '#up' do
it "imports all prometheus metrics" do it "imports all prometheus metrics" do
expect(PrometheusMetric.common).to be_empty expect(PrometheusMetric.common).to be_empty
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20191216183532_insert_project_hooks_plan_limits.rb') require Rails.root.join('db', 'migrate', '20191216183532_insert_project_hooks_plan_limits.rb')
describe InsertProjectHooksPlanLimits, :migration do describe InsertProjectHooksPlanLimits do
let(:migration) { described_class.new } let(:migration) { described_class.new }
let(:plans) { table(:plans) } let(:plans) { table(:plans) }
let(:plan_limits) { table(:plan_limits) } let(:plan_limits) { table(:plan_limits) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190204115450_migrate_auto_dev_ops_domain_to_cluster_domain.rb') require Rails.root.join('db', 'post_migrate', '20190204115450_migrate_auto_dev_ops_domain_to_cluster_domain.rb')
describe MigrateAutoDevOpsDomainToClusterDomain, :migration do describe MigrateAutoDevOpsDomainToClusterDomain do
include MigrationHelpers::ClusterHelpers include MigrationHelpers::ClusterHelpers
let(:migration) { described_class.new } let(:migration) { described_class.new }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190827102026_migrate_code_owner_approval_status_to_protected_branches_in_batches.rb') require Rails.root.join('db', 'post_migrate', '20190827102026_migrate_code_owner_approval_status_to_protected_branches_in_batches.rb')
describe MigrateCodeOwnerApprovalStatusToProtectedBranchesInBatches, :migration do describe MigrateCodeOwnerApprovalStatusToProtectedBranchesInBatches do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:protected_branches) { table(:protected_branches) } let(:protected_branches) { table(:protected_branches) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190715193142_migrate_discussion_id_on_promoted_epics.rb') require Rails.root.join('db', 'post_migrate', '20190715193142_migrate_discussion_id_on_promoted_epics.rb')
describe MigrateDiscussionIdOnPromotedEpics, :migration do describe MigrateDiscussionIdOnPromotedEpics do
let(:migration_class) { described_class::MIGRATION } let(:migration_class) { described_class::MIGRATION }
let(:migration_name) { migration_class.to_s.demodulize } let(:migration_name) { migration_class.to_s.demodulize }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20181026091631_migrate_forbidden_redirect_uris.rb') require Rails.root.join('db', 'post_migrate', '20181026091631_migrate_forbidden_redirect_uris.rb')
describe MigrateForbiddenRedirectUris, :migration do describe MigrateForbiddenRedirectUris do
let(:oauth_application) { table(:oauth_applications) } let(:oauth_application) { table(:oauth_applications) }
let(:oauth_access_grant) { table(:oauth_access_grants) } let(:oauth_access_grant) { table(:oauth_access_grants) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190517153211_migrate_k8s_service_integration.rb') require Rails.root.join('db', 'post_migrate', '20190517153211_migrate_k8s_service_integration.rb')
describe MigrateK8sServiceIntegration, :migration do describe MigrateK8sServiceIntegration do
context 'template service' do context 'template service' do
context 'with namespace' do context 'with namespace' do
let!(:service) do let!(:service) do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb') require Rails.root.join('db', 'post_migrate', '20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb')
describe MigrateLegacyArtifactsToJobArtifacts, :migration do describe MigrateLegacyArtifactsToJobArtifacts do
let(:migration_class) { Gitlab::BackgroundMigration::MigrateLegacyArtifacts } let(:migration_class) { Gitlab::BackgroundMigration::MigrateLegacyArtifacts }
let(:migration_name) { migration_class.to_s.demodulize } let(:migration_name) { migration_class.to_s.demodulize }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190606163724_migrate_legacy_managed_clusters_to_unmanaged.rb') require Rails.root.join('db', 'post_migrate', '20190606163724_migrate_legacy_managed_clusters_to_unmanaged.rb')
describe MigrateLegacyManagedClustersToUnmanaged, :migration do describe MigrateLegacyManagedClustersToUnmanaged do
let(:cluster_type) { 'project_type' } let(:cluster_type) { 'project_type' }
let(:created_at) { 1.hour.ago } let(:created_at) { 1.hour.ago }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190613231640_migrate_managed_clusters_with_no_token_to_unmanaged.rb') require Rails.root.join('db', 'post_migrate', '20190613231640_migrate_managed_clusters_with_no_token_to_unmanaged.rb')
describe MigrateManagedClustersWithNoTokenToUnmanaged, :migration do describe MigrateManagedClustersWithNoTokenToUnmanaged do
let(:cluster_type) { 'project_type' } let(:cluster_type) { 'project_type' }
let(:created_at) { Date.new(2018, 11, 1).midnight } let(:created_at) { Date.new(2018, 11, 1).midnight }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180809195358_migrate_null_wiki_access_levels.rb') require Rails.root.join('db', 'post_migrate', '20180809195358_migrate_null_wiki_access_levels.rb')
describe MigrateNullWikiAccessLevels, :migration do describe MigrateNullWikiAccessLevels do
let(:namespaces) { table('namespaces') } let(:namespaces) { table('namespaces') }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:project_features) { table(:project_features) } let(:project_features) { table(:project_features) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20191118211629_migrate_ops_feature_flags_scopes_target_user_ids.rb') require Rails.root.join('db', 'post_migrate', '20191118211629_migrate_ops_feature_flags_scopes_target_user_ids.rb')
describe MigrateOpsFeatureFlagsScopesTargetUserIds, :migration do describe MigrateOpsFeatureFlagsScopesTargetUserIds do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:flags) { table(:operations_feature_flags) } let(:flags) { table(:operations_feature_flags) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20191030152934_move_limits_from_plans.rb') require Rails.root.join('db', 'migrate', '20191030152934_move_limits_from_plans.rb')
describe MoveLimitsFromPlans, :migration do describe MoveLimitsFromPlans do
let(:plans) { table(:plans) } let(:plans) { table(:plans) }
let(:plan_limits) { table(:plan_limits) } let(:plan_limits) { table(:plan_limits) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20191104142124_nullify_users_role.rb') require Rails.root.join('db', 'post_migrate', '20191104142124_nullify_users_role.rb')
describe NullifyUsersRole, :migration do describe NullifyUsersRole do
let(:users) { table(:users) } let(:users) { table(:users) }
before do before do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190418132125_populate_project_statistics_packages_size.rb') require Rails.root.join('db', 'post_migrate', '20190418132125_populate_project_statistics_packages_size.rb')
describe PopulateProjectStatisticsPackagesSize, :migration do describe PopulateProjectStatisticsPackagesSize do
let(:project_statistics) { table(:project_statistics) } let(:project_statistics) { table(:project_statistics) }
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190520201748_populate_rule_type_on_approval_merge_request_rules.rb') require Rails.root.join('db', 'post_migrate', '20190520201748_populate_rule_type_on_approval_merge_request_rules.rb')
describe PopulateRuleTypeOnApprovalMergeRequestRules, :migration do describe PopulateRuleTypeOnApprovalMergeRequestRules do
let(:migration) { described_class.new } let(:migration) { described_class.new }
describe '#up' do describe '#up' do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180220150310_remove_empty_extern_uid_auth0_identities.rb') require Rails.root.join('db', 'post_migrate', '20180220150310_remove_empty_extern_uid_auth0_identities.rb')
describe RemoveEmptyExternUidAuth0Identities, :migration do describe RemoveEmptyExternUidAuth0Identities do
let(:identities) { table(:identities) } let(:identities) { table(:identities) }
before do before do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20191021101942_remove_empty_github_service_templates.rb') require Rails.root.join('db', 'post_migrate', '20191021101942_remove_empty_github_service_templates.rb')
describe RemoveEmptyGithubServiceTemplates, :migration do describe RemoveEmptyGithubServiceTemplates do
subject(:migration) { described_class.new } subject(:migration) { described_class.new }
let(:services) do let(:services) do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20200210135504_remove_packages_deprecated_dependencies.rb') require Rails.root.join('db', 'migrate', '20200210135504_remove_packages_deprecated_dependencies.rb')
describe RemovePackagesDeprecatedDependencies, :migration do describe RemovePackagesDeprecatedDependencies do
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:packages) { table(:packages_packages) } let(:packages) { table(:packages_packages) }
let(:dependency_links) { table(:packages_dependency_links) } let(:dependency_links) { table(:packages_dependency_links) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180119121225_remove_redundant_pipeline_stages.rb') require Rails.root.join('db', 'post_migrate', '20180119121225_remove_redundant_pipeline_stages.rb')
describe RemoveRedundantPipelineStages, :migration do describe RemoveRedundantPipelineStages do
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:pipelines) { table(:ci_pipelines) } let(:pipelines) { table(:ci_pipelines) }
let(:stages) { table(:ci_stages) } let(:stages) { table(:ci_stages) }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200214034836_remove_security_dashboard_feature_flag.rb') require Rails.root.join('db', 'post_migrate', '20200214034836_remove_security_dashboard_feature_flag.rb')
describe RemoveSecurityDashboardFeatureFlag, :migration do describe RemoveSecurityDashboardFeatureFlag do
let(:feature_gates) { table(:feature_gates) } let(:feature_gates) { table(:feature_gates) }
subject(:migration) { described_class.new } subject(:migration) { described_class.new }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
require Rails.root.join('db', 'migrate', '20200212014653_rename_security_dashboard_feature_flag_to_instance_security_dashboard.rb') require Rails.root.join('db', 'migrate', '20200212014653_rename_security_dashboard_feature_flag_to_instance_security_dashboard.rb')
describe RenameSecurityDashboardFeatureFlagToInstanceSecurityDashboard, :migration do describe RenameSecurityDashboardFeatureFlagToInstanceSecurityDashboard do
let(:feature_gates) { table(:feature_gates) } let(:feature_gates) { table(:feature_gates) }
subject(:migration) { described_class.new } subject(:migration) { described_class.new }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180405101928_reschedule_builds_stages_migration') require Rails.root.join('db', 'post_migrate', '20180405101928_reschedule_builds_stages_migration')
describe RescheduleBuildsStagesMigration, :migration do describe RescheduleBuildsStagesMigration do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:pipelines) { table(:ci_pipelines) } let(:pipelines) { table(:ci_pipelines) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20180309121820_reschedule_commits_count_for_merge_request_diff') require Rails.root.join('db', 'migrate', '20180309121820_reschedule_commits_count_for_merge_request_diff')
describe RescheduleCommitsCountForMergeRequestDiff, :migration do describe RescheduleCommitsCountForMergeRequestDiff do
let(:merge_request_diffs) { table(:merge_request_diffs) } let(:merge_request_diffs) { table(:merge_request_diffs) }
let(:merge_requests) { table(:merge_requests) } let(:merge_requests) { table(:merge_requests) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200210092405_save_instance_administrators_group_id') require Rails.root.join('db', 'post_migrate', '20200210092405_save_instance_administrators_group_id')
describe SaveInstanceAdministratorsGroupId, :migration do describe SaveInstanceAdministratorsGroupId do
let(:application_settings_table) { table(:application_settings) } let(:application_settings_table) { table(:application_settings) }
let(:instance_administrators_group) do let(:instance_administrators_group) do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180913142237_schedule_digest_personal_access_tokens.rb') require Rails.root.join('db', 'post_migrate', '20180913142237_schedule_digest_personal_access_tokens.rb')
describe ScheduleDigestPersonalAccessTokens, :migration do describe ScheduleDigestPersonalAccessTokens do
let(:personal_access_tokens) { table(:personal_access_tokens) } let(:personal_access_tokens) { table(:personal_access_tokens) }
let(:users) { table(:users) } let(:users) { table(:users) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190524073827_schedule_fill_valid_time_for_pages_domain_certificates.rb') require Rails.root.join('db', 'post_migrate', '20190524073827_schedule_fill_valid_time_for_pages_domain_certificates.rb')
describe ScheduleFillValidTimeForPagesDomainCertificates, :migration do describe ScheduleFillValidTimeForPagesDomainCertificates do
let(:migration_class) { described_class::MIGRATION } let(:migration_class) { described_class::MIGRATION }
let(:migration_name) { migration_class.to_s.demodulize } let(:migration_name) { migration_class.to_s.demodulize }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200217225719_schedule_migrate_security_scans.rb') require Rails.root.join('db', 'post_migrate', '20200217225719_schedule_migrate_security_scans.rb')
# rubocop: disable RSpec/FactoriesInMigrationSpecs # rubocop: disable RSpec/FactoriesInMigrationSpecs
describe ScheduleMigrateSecurityScans, :migration, :sidekiq do describe ScheduleMigrateSecurityScans, :sidekiq do
let(:migration) { described_class.new } let(:migration) { described_class.new }
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20191002031332_schedule_pages_metadata_migration') require Rails.root.join('db', 'post_migrate', '20191002031332_schedule_pages_metadata_migration')
describe SchedulePagesMetadataMigration, :migration do describe SchedulePagesMetadataMigration do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190322132835_schedule_populate_merge_request_assignees_table.rb') require Rails.root.join('db', 'post_migrate', '20190322132835_schedule_populate_merge_request_assignees_table.rb')
describe SchedulePopulateMergeRequestAssigneesTable, :migration do describe SchedulePopulateMergeRequestAssigneesTable do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') } let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200204113224_schedule_recalculate_project_authorizations_second_run.rb') require Rails.root.join('db', 'post_migrate', '20200204113224_schedule_recalculate_project_authorizations_second_run.rb')
describe ScheduleRecalculateProjectAuthorizationsSecondRun, :migration do describe ScheduleRecalculateProjectAuthorizationsSecondRun do
let(:users_table) { table(:users) } let(:users_table) { table(:users) }
before do before do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200204113223_schedule_recalculate_project_authorizations.rb') require Rails.root.join('db', 'post_migrate', '20200204113223_schedule_recalculate_project_authorizations.rb')
describe ScheduleRecalculateProjectAuthorizations, :migration do describe ScheduleRecalculateProjectAuthorizations do
let(:users_table) { table(:users) } let(:users_table) { table(:users) }
let(:namespaces_table) { table(:namespaces) } let(:namespaces_table) { table(:namespaces) }
let(:projects_table) { table(:projects) } let(:projects_table) { table(:projects) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20181121111200_schedule_runners_token_encryption') require Rails.root.join('db', 'post_migrate', '20181121111200_schedule_runners_token_encryption')
describe ScheduleRunnersTokenEncryption, :migration do describe ScheduleRunnersTokenEncryption do
let(:settings) { table(:application_settings) } let(:settings) { table(:application_settings) }
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180104131052_schedule_set_confidential_note_events_on_webhooks.rb') require Rails.root.join('db', 'post_migrate', '20180104131052_schedule_set_confidential_note_events_on_webhooks.rb')
describe ScheduleSetConfidentialNoteEventsOnWebhooks, :migration do describe ScheduleSetConfidentialNoteEventsOnWebhooks do
let(:web_hooks_table) { table(:web_hooks) } let(:web_hooks_table) { table(:web_hooks) }
let(:migration_class) { Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks } let(:migration_class) { Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks }
let(:migration_name) { migration_class.to_s.demodulize } let(:migration_name) { migration_class.to_s.demodulize }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180420080616_schedule_stages_index_migration') require Rails.root.join('db', 'post_migrate', '20180420080616_schedule_stages_index_migration')
describe ScheduleStagesIndexMigration, :migration do describe ScheduleStagesIndexMigration do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:pipelines) { table(:ci_pipelines) } let(:pipelines) { table(:ci_pipelines) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190214112022_schedule_sync_issuables_state_id.rb') require Rails.root.join('db', 'post_migrate', '20190214112022_schedule_sync_issuables_state_id.rb')
describe ScheduleSyncIssuablesStateId, :migration do describe ScheduleSyncIssuablesStateId do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:merge_requests) { table(:merge_requests) } let(:merge_requests) { table(:merge_requests) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190506135400_schedule_sync_issuables_state_id_where_nil') require Rails.root.join('db', 'post_migrate', '20190506135400_schedule_sync_issuables_state_id_where_nil')
describe ScheduleSyncIssuablesStateIdWhereNil, :migration do describe ScheduleSyncIssuablesStateIdWhereNil do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:merge_requests) { table(:merge_requests) } let(:merge_requests) { table(:merge_requests) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180529152628_schedule_to_archive_legacy_traces') require Rails.root.join('db', 'post_migrate', '20180529152628_schedule_to_archive_legacy_traces')
describe ScheduleToArchiveLegacyTraces, :migration do describe ScheduleToArchiveLegacyTraces do
include TraceHelpers include TraceHelpers
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200110121314_schedule_update_existing_subgroup_to_match_visibility_level_of_parent.rb') require Rails.root.join('db', 'post_migrate', '20200110121314_schedule_update_existing_subgroup_to_match_visibility_level_of_parent.rb')
describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent, :migration do describe ScheduleUpdateExistingSubgroupToMatchVisibilityLevelOfParent do
include MigrationHelpers::NamespacesHelpers include MigrationHelpers::NamespacesHelpers
let(:migration_class) { described_class::MIGRATION } let(:migration_class) { described_class::MIGRATION }
let(:migration_name) { migration_class.to_s.demodulize } let(:migration_name) { migration_class.to_s.demodulize }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200203104214_services_remove_temporary_index_on_project_id.rb') require Rails.root.join('db', 'post_migrate', '20200203104214_services_remove_temporary_index_on_project_id.rb')
describe ServicesRemoveTemporaryIndexOnProjectId, :migration do describe ServicesRemoveTemporaryIndexOnProjectId do
let(:migration_instance) { described_class.new } let(:migration_instance) { described_class.new }
it 'adds and removes temporary partial index in up and down methods' do it 'adds and removes temporary partial index in up and down methods' do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20190715043954_set_issue_id_for_all_versions.rb') require Rails.root.join('db', 'migrate', '20190715043954_set_issue_id_for_all_versions.rb')
describe SetIssueIdForAllVersions, :migration do describe SetIssueIdForAllVersions do
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:issues) { table(:issues) } let(:issues) { table(:issues) }
let(:designs) { table(:design_management_designs) } let(:designs) { table(:design_management_designs) }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20181105201455_steal_fill_store_upload.rb') require Rails.root.join('db', 'post_migrate', '20181105201455_steal_fill_store_upload.rb')
describe StealFillStoreUpload, :migration do describe StealFillStoreUpload do
let(:uploads) { table(:uploads) } let(:uploads) { table(:uploads) }
describe '#up' do describe '#up' do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190911251732_sync_issuables_state_id') require Rails.root.join('db', 'post_migrate', '20190911251732_sync_issuables_state_id')
describe SyncIssuablesStateId, :migration do describe SyncIssuablesStateId do
let(:migration) { described_class.new } let(:migration) { described_class.new }
describe '#up' do describe '#up' do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20190325080727_truncate_user_fullname.rb') require Rails.root.join('db', 'migrate', '20190325080727_truncate_user_fullname.rb')
describe TruncateUserFullname, :migration do describe TruncateUserFullname do
let(:users) { table(:users) } let(:users) { table(:users) }
let(:user_short) { create_user(name: 'abc', email: 'test_short@example.com') } let(:user_short) { create_user(name: 'abc', email: 'test_short@example.com') }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'migrate', '20200221105436_update_application_setting_npm_package_requests_forwarding_default.rb') require Rails.root.join('db', 'migrate', '20200221105436_update_application_setting_npm_package_requests_forwarding_default.rb')
describe UpdateApplicationSettingNpmPackageRequestsForwardingDefault, :migration do describe UpdateApplicationSettingNpmPackageRequestsForwardingDefault do
# Create test data - pipeline and CI/CD jobs. # Create test data - pipeline and CI/CD jobs.
let(:application_settings) { table(:application_settings) } let(:application_settings) { table(:application_settings) }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20200106071113_update_fingerprint_sha256_within_keys.rb') require Rails.root.join('db', 'post_migrate', '20200106071113_update_fingerprint_sha256_within_keys.rb')
describe UpdateFingerprintSha256WithinKeys, :migration do describe UpdateFingerprintSha256WithinKeys do
let(:key_table) { table(:keys) } let(:key_table) { table(:keys) }
describe '#up' do describe '#up' do
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20191205084057_update_minimum_password_length') require Rails.root.join('db', 'post_migrate', '20191205084057_update_minimum_password_length')
describe UpdateMinimumPasswordLength, :migration do describe UpdateMinimumPasswordLength do
let(:application_settings) { table(:application_settings) } let(:application_settings) { table(:application_settings) }
let(:application_setting) do let(:application_setting) do
application_settings.create!( application_settings.create!(
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20181219130552_update_project_import_visibility_level.rb') require Rails.root.join('db', 'post_migrate', '20181219130552_update_project_import_visibility_level.rb')
describe UpdateProjectImportVisibilityLevel, :migration do describe UpdateProjectImportVisibilityLevel do
let(:namespaces) { table(:namespaces) } let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:project) { projects.find_by_name(name) } let(:project) { projects.find_by_name(name) }
......
...@@ -4,7 +4,7 @@ require 'spec_helper' ...@@ -4,7 +4,7 @@ require 'spec_helper'
require Rails.root.join('db', 'migrate', '20200116175538_update_timestamp_softwarelicensespolicy.rb') require Rails.root.join('db', 'migrate', '20200116175538_update_timestamp_softwarelicensespolicy.rb')
describe UpdateTimestampSoftwarelicensespolicy, :migration do describe UpdateTimestampSoftwarelicensespolicy do
let(:software_licenses_policy) { table(:software_license_policies) } let(:software_licenses_policy) { table(:software_license_policies) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:licenses) { table(:software_licenses) } let(:licenses) { table(:software_licenses) }
......
...@@ -195,56 +195,71 @@ describe API::DeployTokens do ...@@ -195,56 +195,71 @@ describe API::DeployTokens do
end end
end end
describe 'POST /projects/:id/deploy_tokens' do context 'deploy token creation' do
let(:params) do shared_examples 'creating a deploy token' do |entity, unauthenticated_response|
{ let(:params) do
name: 'Foo', {
expires_at: 1.year.from_now, name: 'Foo',
scopes: [ expires_at: 1.year.from_now,
'read_repository' scopes: [
], 'read_repository'
username: 'Bar' ],
} username: 'Bar'
end }
end
subject do context 'when unauthenticated' do
post api("/projects/#{project.id}/deploy_tokens", user), params: params let(:user) { nil }
response
end
context 'when unauthenticated' do it { is_expected.to have_gitlab_http_status(unauthenticated_response) }
let(:user) { nil } end
it { is_expected.to have_gitlab_http_status(:not_found) } context 'when authenticated as non-admin user' do
end before do
send(entity).add_developer(user)
end
context 'when authenticated as non-admin user' do it { is_expected.to have_gitlab_http_status(:forbidden) }
before do
project.add_developer(user)
end end
it { is_expected.to have_gitlab_http_status(:forbidden) } context 'when authenticated as maintainer' do
end before do
send(entity).add_maintainer(user)
end
context 'when authenticated as maintainer' do it 'creates the deploy token' do
before do expect { subject }.to change { DeployToken.count }.by(1)
project.add_maintainer(user)
end
it 'creates the deploy token' do expect(response).to have_gitlab_http_status(:created)
expect { subject }.to change { DeployToken.count }.by(1) expect(response).to match_response_schema('public_api/v4/deploy_token')
end
expect(response).to have_gitlab_http_status(:created) context 'with an invalid scope' do
expect(response).to match_response_schema('public_api/v4/deploy_token') before do
end params[:scopes] = %w[read_repository all_access]
end
context 'with an invalid scope' do it { is_expected.to have_gitlab_http_status(:bad_request) }
before do
params[:scopes] = %w[read_repository all_access]
end end
end
end
describe 'POST /projects/:id/deploy_tokens' do
subject do
post api("/projects/#{project.id}/deploy_tokens", user), params: params
response
end
it_behaves_like 'creating a deploy token', :project, :not_found
end
it { is_expected.to have_gitlab_http_status(:bad_request) } describe 'POST /groups/:id/deploy_tokens' do
subject do
post api("/groups/#{group.id}/deploy_tokens", user), params: params
response
end end
it_behaves_like 'creating a deploy token', :group, :forbidden
end end
end end
end end
...@@ -488,6 +488,7 @@ describe 'project routing' do ...@@ -488,6 +488,7 @@ describe 'project routing' do
end end
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/project_members", "/gitlab/gitlabhq/-/project_members" it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/project_members", "/gitlab/gitlabhq/-/project_members"
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/-/settings/members", "/gitlab/gitlabhq/-/project_members"
end end
# project_milestones GET /:project_id/milestones(.:format) milestones#index # project_milestones GET /:project_id/milestones(.:format) milestones#index
......
...@@ -8,18 +8,27 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do ...@@ -8,18 +8,27 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do
let(:new_oids) { { 'oid1' => 123, 'oid2' => 125 } } let(:new_oids) { { 'oid1' => 123, 'oid2' => 125 } }
let(:remote_uri) { URI.parse(lfs_endpoint) } let(:remote_uri) { URI.parse(lfs_endpoint) }
let(:objects_response) do let(:request_object) { HTTParty::Request.new(Net::HTTP::Post, '/') }
body = new_oids.map do |oid, size| let(:parsed_block) { lambda {} }
let(:success_net_response) { Net::HTTPOK.new('', '', '') }
let(:response) { Gitlab::HTTP::Response.new(request_object, net_response, parsed_block) }
def objects_response(oids)
body = oids.map do |oid, size|
{ {
'oid' => oid, 'oid' => oid, 'size' => size,
'size' => size,
'actions' => { 'actions' => {
'download' => { 'href' => "#{import_url}/gitlab-lfs/objects/#{oid}" } 'download' => { 'href' => "#{import_url}/gitlab-lfs/objects/#{oid}" }
} }
} }
end end
Struct.new(:success?, :objects).new(true, body) Struct.new(:success?, :objects).new(true, body).to_json
end
def custom_response(net_response, body = nil)
allow(net_response).to receive(:body).and_return(body)
Gitlab::HTTP::Response.new(request_object, net_response, parsed_block)
end end
let(:invalid_object_response) do let(:invalid_object_response) do
...@@ -33,9 +42,8 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do ...@@ -33,9 +42,8 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do
before do before do
allow(project).to receive(:lfs_enabled?).and_return(true) allow(project).to receive(:lfs_enabled?).and_return(true)
response = instance_double(Gitlab::HTTP::Response)
allow(response).to receive(:body).and_return(objects_response.to_json) response = custom_response(success_net_response, objects_response(new_oids))
allow(response).to receive(:success?).and_return(true)
allow(Gitlab::HTTP).to receive(:post).and_return(response) allow(Gitlab::HTTP).to receive(:post).and_return(response)
end end
...@@ -46,6 +54,102 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do ...@@ -46,6 +54,102 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do
end end
end end
context 'when lfs objects size is larger than the batch size' do
def stub_successful_request(batch)
response = custom_response(success_net_response, objects_response(batch))
stub_request(batch, response)
end
def stub_entity_too_large_error_request(batch)
entity_too_large_net_response = Net::HTTPRequestEntityTooLarge.new('', '', '')
response = custom_response(entity_too_large_net_response)
stub_request(batch, response)
end
def stub_request(batch, response)
expect(Gitlab::HTTP).to receive(:post).with(
remote_uri,
{
body: { operation: 'download', objects: batch.map { |k, v| { oid: k, size: v } } }.to_json,
headers: subject.send(:headers)
}
).and_return(response)
end
let(:new_oids) { { 'oid1' => 123, 'oid2' => 125, 'oid3' => 126, 'oid4' => 127, 'oid5' => 128 } }
context 'when batch size' do
before do
stub_const("#{described_class.name}::REQUEST_BATCH_SIZE", 2)
data = new_oids.to_a
stub_successful_request([data[0], data[1]])
stub_successful_request([data[2], data[3]])
stub_successful_request([data[4]])
end
it 'retreives them in batches' do
subject.execute(new_oids).each do |lfs_download_object|
expect(lfs_download_object.link).to eq "#{import_url}/gitlab-lfs/objects/#{lfs_download_object.oid}"
end
end
end
context 'when request fails with PayloadTooLarge error' do
let(:error_class) { described_class::DownloadLinksRequestEntityTooLargeError }
context 'when the smaller batch eventually works' do
before do
stub_const("#{described_class.name}::REQUEST_BATCH_SIZE", 5)
data = new_oids.to_a
# with the batch size of 5
stub_entity_too_large_error_request(data)
# with the batch size of 2
stub_successful_request([data[0], data[1]])
stub_successful_request([data[2], data[3]])
stub_successful_request([data[4]])
end
it 'retreives them eventually and logs exceptions' do
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
an_instance_of(error_class), project_id: project.id, batch_size: 5, oids_count: 5
)
subject.execute(new_oids).each do |lfs_download_object|
expect(lfs_download_object.link).to eq "#{import_url}/gitlab-lfs/objects/#{lfs_download_object.oid}"
end
end
end
context 'when batch size cannot be any smaller' do
before do
stub_const("#{described_class.name}::REQUEST_BATCH_SIZE", 5)
data = new_oids.to_a
# with the batch size of 5
stub_entity_too_large_error_request(data)
# with the batch size of 2
stub_entity_too_large_error_request([data[0], data[1]])
end
it 'raises an error and logs exceptions' do
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
an_instance_of(error_class), project_id: project.id, batch_size: 5, oids_count: 5
)
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(
an_instance_of(error_class), project_id: project.id, batch_size: 2, oids_count: 5
)
expect { subject.execute(new_oids) }.to raise_error(described_class::DownloadLinksError)
end
end
end
end
context 'credentials' do context 'credentials' do
context 'when the download link and the lfs_endpoint have the same host' do context 'when the download link and the lfs_endpoint have the same host' do
context 'when lfs_endpoint has credentials' do context 'when lfs_endpoint has credentials' do
...@@ -87,17 +191,22 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do ...@@ -87,17 +191,22 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do
end end
describe '#get_download_links' do describe '#get_download_links' do
it 'raise error if request fails' do context 'if request fails' do
allow(Gitlab::HTTP).to receive(:post).and_return(Struct.new(:success?, :message).new(false, 'Failed request')) before do
request_timeout_net_response = Net::HTTPRequestTimeout.new('', '', '')
response = custom_response(request_timeout_net_response)
allow(Gitlab::HTTP).to receive(:post).and_return(response)
end
expect { subject.send(:get_download_links, new_oids) }.to raise_error(described_class::DownloadLinksError) it 'raises an error' do
expect { subject.send(:get_download_links, new_oids) }.to raise_error(described_class::DownloadLinksError)
end
end end
shared_examples 'JSON parse errors' do |body| shared_examples 'JSON parse errors' do |body|
it 'raises error' do it 'raises an error' do
response = instance_double(Gitlab::HTTP::Response) response = custom_response(success_net_response)
allow(response).to receive(:body).and_return(body) allow(response).to receive(:body).and_return(body)
allow(response).to receive(:success?).and_return(true)
allow(Gitlab::HTTP).to receive(:post).and_return(response) allow(Gitlab::HTTP).to receive(:post).and_return(response)
expect { subject.send(:get_download_links, new_oids) }.to raise_error(described_class::DownloadLinksError) expect { subject.send(:get_download_links, new_oids) }.to raise_error(described_class::DownloadLinksError)
......
...@@ -76,11 +76,16 @@ RSpec.configure do |config| ...@@ -76,11 +76,16 @@ RSpec.configure do |config|
metadata[:level] = quality_level.level_for(location) metadata[:level] = quality_level.level_for(location)
metadata[:api] = true if location =~ %r{/spec/requests/api/} metadata[:api] = true if location =~ %r{/spec/requests/api/}
# do not overwrite type if it's already set # Do not overwrite migration if it's already set
next if metadata.key?(:type) unless metadata.key?(:migration)
metadata[:migration] = true if metadata[:level] == :migration
end
match = location.match(%r{/spec/([^/]+)/}) # Do not overwrite type if it's already set
metadata[:type] = match[1].singularize.to_sym if match unless metadata.key?(:type)
match = location.match(%r{/spec/([^/]+)/})
metadata[:type] = match[1].singularize.to_sym if match
end
end end
config.include LicenseHelpers config.include LicenseHelpers
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment