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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-12-18 03:14:00 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-12-18 03:14:00 +0300
commite1d036885e2f5720e847d9009f60c5d7baad0015 (patch)
tree2fd1a36b792ff2e7d71944d28cb1473dfe22cde4
parent6bdb805dc87064d97d303ce8864f30e48663c6e9 (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--.gitlab/ci/rails.gitlab-ci.yml6
-rw-r--r--app/controllers/registrations/welcome_controller.rb4
-rw-r--r--app/experiments/combined_registration_experiment.rb6
-rw-r--r--app/models/concerns/issuable.rb6
-rw-r--r--config/feature_flags/experiment/force_company_trial.yml8
-rw-r--r--db/post_migrate/20210713042000_fix_ci_sources_pipelines_index_names.rb59
-rw-r--r--db/schema_migrations/202107130420001
-rw-r--r--doc/api/project_level_variables.md10
-rw-r--r--doc/user/application_security/container_scanning/index.md22
-rw-r--r--doc/user/application_security/dependency_scanning/index.md17
-rw-r--r--doc/user/clusters/agent/index.md4
-rw-r--r--doc/user/clusters/agent/install/index.md4
-rw-r--r--doc/user/clusters/agent/repository.md8
-rw-r--r--doc/user/clusters/cost_management.md3
-rw-r--r--doc/user/clusters/environments.md4
-rw-r--r--doc/user/clusters/migrating_from_gma_to_project_template.md2
-rw-r--r--spec/frontend/__helpers__/experimentation_helper.js2
-rw-r--r--spec/graphql/resolvers/users/participants_resolver_spec.rb30
-rw-r--r--spec/migrations/20210713042000_fix_ci_sources_pipelines_index_names_spec.rb67
-rw-r--r--spec/models/integrations/microsoft_teams_spec.rb11
-rw-r--r--spec/support/shared_examples/models/chat_integration_shared_examples.rb8
21 files changed, 225 insertions, 57 deletions
diff --git a/.gitlab/ci/rails.gitlab-ci.yml b/.gitlab/ci/rails.gitlab-ci.yml
index 7ea247f8353..d676dc2f331 100644
--- a/.gitlab/ci/rails.gitlab-ci.yml
+++ b/.gitlab/ci/rails.gitlab-ci.yml
@@ -349,6 +349,12 @@ db:rollback:
- scripts/db_tasks db:migrate VERSION=20181228175414
- scripts/db_tasks db:migrate SKIP_SCHEMA_VERSION_CHECK=true
+db:rollback decomposed:
+ extends:
+ - db:rollback
+ - .decomposed-database
+ - .rails:rules:decomposed-databases
+
db:migrate:reset:
extends: .db-job-base
script:
diff --git a/app/controllers/registrations/welcome_controller.rb b/app/controllers/registrations/welcome_controller.rb
index 507b3f8fdf4..41fd1b7a1e6 100644
--- a/app/controllers/registrations/welcome_controller.rb
+++ b/app/controllers/registrations/welcome_controller.rb
@@ -76,10 +76,6 @@ module Registrations
end
# overridden in EE
- def trial_params
- end
-
- # overridden in EE
def update_success_path
end
end
diff --git a/app/experiments/combined_registration_experiment.rb b/app/experiments/combined_registration_experiment.rb
index da699449d77..08c015838db 100644
--- a/app/experiments/combined_registration_experiment.rb
+++ b/app/experiments/combined_registration_experiment.rb
@@ -7,14 +7,12 @@ class CombinedRegistrationExperiment < ApplicationExperiment # rubocop:disable G
super(source, 'force_company_trial')
end
- def redirect_path(trial_params)
- @trial_params = trial_params
-
+ def redirect_path
run
end
def control_behavior
- new_users_sign_up_group_path(@trial_params)
+ new_users_sign_up_group_path
end
def candidate_behavior
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 1f05aa0954d..dcd80201d3f 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -66,6 +66,11 @@ module Issuable
# We check first if we're loaded to not load unnecessarily.
loaded? && to_a.all? { |note| note.association(:project).loaded? }
end
+
+ def system_note_metadata_loaded?
+ # We check first if we're loaded to not load unnecessarily.
+ loaded? && to_a.all? { |note| note.association(:system_note_metadata).loaded? }
+ end
end
has_many :note_authors, -> { distinct }, through: :notes, source: :author
@@ -534,6 +539,7 @@ module Issuable
includes << :author unless notes.authors_loaded?
includes << :award_emoji unless notes.award_emojis_loaded?
includes << :project unless notes.projects_loaded?
+ includes << :system_note_metadata unless notes.system_note_metadata_loaded?
if includes.any?
notes.includes(includes)
diff --git a/config/feature_flags/experiment/force_company_trial.yml b/config/feature_flags/experiment/force_company_trial.yml
deleted file mode 100644
index 85fc789085d..00000000000
--- a/config/feature_flags/experiment/force_company_trial.yml
+++ /dev/null
@@ -1,8 +0,0 @@
----
-name: force_company_trial
-introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/65287
-rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/335050
-milestone: '14.1'
-type: experiment
-group: group::adoption
-default_enabled: false
diff --git a/db/post_migrate/20210713042000_fix_ci_sources_pipelines_index_names.rb b/db/post_migrate/20210713042000_fix_ci_sources_pipelines_index_names.rb
new file mode 100644
index 00000000000..34701d8ba46
--- /dev/null
+++ b/db/post_migrate/20210713042000_fix_ci_sources_pipelines_index_names.rb
@@ -0,0 +1,59 @@
+# frozen_string_literal: true
+
+# When the `ci_sources_pipelines` table was first introduced in GitLab
+# 9.3 EE, the foreign key names generate for the table appeared to
+# have been calculated via a hash using the table name
+# `ci_pipeline_source_pipelines`. This led to a merge conflict and
+# confusion during a CE to EE merge in GitLab 10.0, which regenerated
+# the schema with the correct foreign key names.
+#
+# Hence anyone who installed GitLab prior to 10.0 may have been seeded
+# the database with stale, incorrect foreign key names.
+#
+# During the Great BigInt Conversion of 2021, several migrations
+# assumed that the foreign key `fk_be5624bf37` existed for
+# `ci_sources_pipeline`. However, older installations may have had the
+# correct foreign key under the name `fk_3f0c88d7dc`.
+#
+# To eliminate future confusion and migration failures, we now rename
+# the foreign key constraints and index to what they should be today.
+class FixCiSourcesPipelinesIndexNames < ActiveRecord::Migration[6.1]
+ include Gitlab::Database::MigrationHelpers
+
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'ci_sources_pipelines'
+
+ # GitLab 9.5.4: https://gitlab.com/gitlab-org/gitlab/-/blob/v9.5.4-ee/db/schema.rb#L2026-2030
+ # GitLab 10.0: https://gitlab.com/gitlab-org/gitlab/-/blob/v10.0.0-ee/db/schema.rb#L2064-2068
+ OLD_TO_NEW_FOREIGN_KEY_DEFS = {
+ 'fk_3f0c88d7dc' => { table: :ci_builds, column: :source_job_id, name: 'fk_be5624bf37' },
+ 'fk_b8c0fac459' => { table: :ci_pipelines, column: :pipeline_id, name: 'fk_e1bad85861' },
+ 'fk_3a3e3cb83a' => { table: :ci_pipelines, column: :source_pipeline_id, name: 'fk_d4e29af7d7' },
+ 'fk_8868d0f3e4' => { table: :projects, column: :source_project_id, name: 'fk_acd9737679' },
+ 'fk_83b4346e48' => { table: :projects, name: 'fk_1e53c97c0a' }
+ }
+ OLD_INDEX_NAME = 'index_ci_pipeline_source_pipelines_on_source_job_id'
+ NEW_INDEX_NAME = 'index_ci_sources_pipelines_on_source_job_id'
+
+ def up
+ OLD_TO_NEW_FOREIGN_KEY_DEFS.each do |old_name, entry|
+ options = { column: entry[:column], name: old_name }.compact
+
+ if foreign_key_exists?(TABLE_NAME, entry[:table], **options)
+ rename_constraint(TABLE_NAME, old_name, entry[:name])
+ end
+ end
+
+ if index_exists_by_name?(TABLE_NAME, OLD_INDEX_NAME)
+ if index_exists_by_name?(TABLE_NAME, NEW_INDEX_NAME)
+ remove_concurrent_index_by_name(TABLE_NAME, OLD_INDEX_NAME)
+ else
+ rename_index(TABLE_NAME, OLD_INDEX_NAME, NEW_INDEX_NAME)
+ end
+ end
+ end
+
+ # There's no reason to revert this change since it should apply on stale schemas
+ def down; end
+end
diff --git a/db/schema_migrations/20210713042000 b/db/schema_migrations/20210713042000
new file mode 100644
index 00000000000..ed775d6e188
--- /dev/null
+++ b/db/schema_migrations/20210713042000
@@ -0,0 +1 @@
+ede336cca4f5d692fb9fccb60db7846a917d887412a10699e818a6caf0ef6a45 \ No newline at end of file
diff --git a/doc/api/project_level_variables.md b/doc/api/project_level_variables.md
index a2c2da9065f..2251b0fc7fd 100644
--- a/doc/api/project_level_variables.md
+++ b/doc/api/project_level_variables.md
@@ -15,7 +15,7 @@ Get list of a project's variables.
GET /projects/:id/variables
```
-| Attribute | Type | required | Description |
+| Attribute | Type | Required | Description |
| --------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | integer/string | yes | The ID of a project or [URL-encoded NAMESPACE/PROJECT_NAME of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
@@ -52,7 +52,7 @@ Get the details of a project's specific variable.
GET /projects/:id/variables/:key
```
-| Attribute | Type | required | Description |
+| Attribute | Type | Required | Description |
| --------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | integer/string | yes | The ID of a project or [URL-encoded NAMESPACE/PROJECT_NAME of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
| `key` | string | yes | The `key` of a variable |
@@ -81,7 +81,7 @@ Create a new variable.
POST /projects/:id/variables
```
-| Attribute | Type | required | Description |
+| Attribute | Type | Required | Description |
| ------------------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | integer/string | yes | The ID of a project or [URL-encoded NAMESPACE/PROJECT_NAME of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
| `key` | string | yes | The `key` of a variable; must have no more than 255 characters; only `A-Z`, `a-z`, `0-9`, and `_` are allowed |
@@ -115,7 +115,7 @@ Update a project's variable.
PUT /projects/:id/variables/:key
```
-| Attribute | Type | required | Description |
+| Attribute | Type | Required | Description |
| ------------------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | integer/string | yes | The ID of a project or [URL-encoded NAMESPACE/PROJECT_NAME of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
| `key` | string | yes | The `key` of a variable |
@@ -150,7 +150,7 @@ Remove a project's variable.
DELETE /projects/:id/variables/:key
```
-| Attribute | Type | required | Description |
+| Attribute | Type | Required | Description |
| --------- | -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `id` | integer/string | yes | The ID of a project or [URL-encoded NAMESPACE/PROJECT_NAME of the project](index.md#namespaced-path-encoding) owned by the authenticated user |
| `key` | string | yes | The `key` of a variable |
diff --git a/doc/user/application_security/container_scanning/index.md b/doc/user/application_security/container_scanning/index.md
index c5d91f709dd..bea9284873c 100644
--- a/doc/user/application_security/container_scanning/index.md
+++ b/doc/user/application_security/container_scanning/index.md
@@ -10,14 +10,26 @@ info: To determine the technical writer assigned to the Stage/Group associated w
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/3672) in GitLab 10.4.
INFO:
-Want to try out container scanning?
-[Get a free 30-day trial of GitLab Ultimate](https://about.gitlab.com/free-trial/index.html?glm_source=docs.gitlab.com&glm_content=u-container-scanning-docs).
+Try out Container Scanning in GitLab Ultimate.
+[It's free for 30 days](https://about.gitlab.com/free-trial/index.html?glm_source=docs.gitlab.com&glm_content=u-container-scanning-docs).
Your application's Docker image may itself be based on Docker images that contain known
-vulnerabilities. By including an extra job in your pipeline that scans for those vulnerabilities and
-displays them in a merge request, you can use GitLab to audit your Docker-based apps.
+vulnerabilities. By including an extra Container Scanning job in your pipeline that scans for those
+vulnerabilities and displays them in a merge request, you can use GitLab to audit your Docker-based
+apps.
-GitLab provides integration with open-source tools for vulnerability static analysis in containers:
+Container Scanning is often considered part of Software Composition Analysis (SCA). SCA can contain
+aspects of inspecting the items your code uses. These items typically include application and system
+dependencies that are almost always imported from external sources, rather than sourced from items
+you wrote yourself.
+
+GitLab offers both Container Scanning and [Dependency Scanning](../dependency_scanning/)
+to ensure coverage for all of these dependency types. To cover as much of your risk area as
+possible, we encourage you to use all of our security scanners.
+
+## Overview
+
+GitLab integrates with open-source tools for vulnerability static analysis in containers:
- [Trivy](https://github.com/aquasecurity/trivy)
- [Grype](https://github.com/anchore/grype)
diff --git a/doc/user/application_security/dependency_scanning/index.md b/doc/user/application_security/dependency_scanning/index.md
index 7d0da456ce2..192d8449297 100644
--- a/doc/user/application_security/dependency_scanning/index.md
+++ b/doc/user/application_security/dependency_scanning/index.md
@@ -16,15 +16,14 @@ software dependencies while you're developing and testing your applications. For
dependency scanning lets you know if your application uses an external (open source)
library that is known to be vulnerable. You can then take action to protect your application.
-Dependency Scanning is often considered part of Software Composition Analysis (SCA).
-SCA can contain various aspects of inspecting the items used in your code. These items
-typically include both application dependencies and system dependencies that are
-almost always imported from external sources, rather than sourced from items you wrote yourself.
-
-At GitLab, we use two separate scanning capabilities to ensure coverage for all of
-these dependency types: Dependency Scanning and Container Scanning. Both are included
-in GitLab Ultimate. We encourage you to use all of our scanners whenever possible
-to cover as much of your risk area as possible:
+Dependency Scanning is often considered part of Software Composition Analysis (SCA). SCA can contain
+aspects of inspecting the items your code uses. These items typically include application and system
+dependencies that are almost always imported from external sources, rather than sourced from items
+you wrote yourself.
+
+GitLab offers both Dependency Scanning and Container Scanning
+to ensure coverage for all of these dependency types. To cover as much of your risk area as
+possible, we encourage you to use all of our security scanners:
- Dependency Scanning analyzes your project and tells you which software dependencies,
including upstream dependencies, have been included in your project, and what known
diff --git a/doc/user/clusters/agent/index.md b/doc/user/clusters/agent/index.md
index 525362cc562..c950a4f0dc0 100644
--- a/doc/user/clusters/agent/index.md
+++ b/doc/user/clusters/agent/index.md
@@ -6,11 +6,11 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# GitLab Agent for Kubernetes **(FREE)**
-> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/223061) in [GitLab Premium](https://about.gitlab.com/pricing/) 13.4.
+> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/223061) in GitLab 13.4.
> - Support for `grpcs` [introduced](https://gitlab.com/gitlab-org/cluster-integration/gitlab-agent/-/issues/7) in GitLab 13.6.
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/300960) in GitLab 13.10, KAS became available on GitLab.com under `wss://kas.gitlab.com` through an Early Adopter Program.
> - Introduced in GitLab 13.11, the GitLab Agent became available to every project on GitLab.com.
-> - The GitLab Agent was [moved](https://gitlab.com/groups/gitlab-org/-/epics/6290) to GitLab Free in 14.5.
+> - [Moved](https://gitlab.com/groups/gitlab-org/-/epics/6290) from GitLab Premium to GitLab Free in 14.5.
> - [Renamed](https://gitlab.com/groups/gitlab-org/-/epics/7167) from "GitLab Kubernetes Agent" to "GitLab Agent for Kubernetes" in GitLab 14.6.
The [GitLab Agent for Kubernetes](https://gitlab.com/gitlab-org/cluster-integration/gitlab-agent) ("Agent", for short)
diff --git a/doc/user/clusters/agent/install/index.md b/doc/user/clusters/agent/install/index.md
index 212eb17054d..deb8599a9f8 100644
--- a/doc/user/clusters/agent/install/index.md
+++ b/doc/user/clusters/agent/install/index.md
@@ -6,7 +6,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Install the GitLab Agent **(FREE)**
-> [Moved](https://gitlab.com/groups/gitlab-org/-/epics/6290) to GitLab Free in 14.5.
+> [Moved](https://gitlab.com/groups/gitlab-org/-/epics/6290) from GitLab Premium to GitLab Free in 14.5.
To get started with the Agent, install it in your cluster.
@@ -30,7 +30,7 @@ To install the [Agent](../index.md) in your cluster:
### Set up the Agent Server
-> [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/3834) in [GitLab Premium](https://about.gitlab.com/pricing/) 13.10, the Agent Server (KAS) became available on GitLab.com under `wss://kas.gitlab.com`.
+> [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/3834) in [GitLab Premium](https://about.gitlab.com/pricing/) 13.10, the GitLab Agent Server (KAS) became available on GitLab.com under `wss://kas.gitlab.com`.
To use the KAS:
diff --git a/doc/user/clusters/agent/repository.md b/doc/user/clusters/agent/repository.md
index 255b39235e5..c8ab037118e 100644
--- a/doc/user/clusters/agent/repository.md
+++ b/doc/user/clusters/agent/repository.md
@@ -6,11 +6,11 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Agent configuration repository **(FREE)**
-> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/259669) in [GitLab Premium](https://about.gitlab.com/pricing/) 13.7.
+> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/259669) in GitLab 13.7.
> - [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/3834) in GitLab 13.11, the GitLab Agent became available on GitLab.com.
+> - [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/5784) the `ci_access` attribute in GitLab 14.3.
+> - [Moved](https://gitlab.com/groups/gitlab-org/-/epics/6290) from GitLab Premium to GitLab Free in 14.5.
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/332227) in GitLab 14.0, the `resource_inclusions` and `resource_exclusions` attributes were removed and `reconcile_timeout`, `dry_run_strategy`, `prune`, `prune_timeout`, `prune_propagation_policy`, and `inventory_policy` attributes were added.
-> - The `ci_access` attribute was [introduced](https://gitlab.com/groups/gitlab-org/-/epics/5784) in GitLab 14.3.
-> - The GitLab Agent was [moved](https://gitlab.com/groups/gitlab-org/-/epics/6290) to GitLab Free in 14.5.
WARNING:
This feature might not be available to you. Check the **version history** note above for details.
@@ -299,7 +299,7 @@ cilium:
hubble_relay_address: "hubble-relay.gitlab-managed-apps.svc.cluster.local:80"
```
-## Scan your container images for vulnerabilities
+## Scan your container images for vulnerabilities **(ULTIMATE)**
You can use [cluster image scanning](../../application_security/cluster_image_scanning/index.md)
to scan container images in your cluster for security vulnerabilities.
diff --git a/doc/user/clusters/cost_management.md b/doc/user/clusters/cost_management.md
index 3ad994ecd7e..14850ca85b3 100644
--- a/doc/user/clusters/cost_management.md
+++ b/doc/user/clusters/cost_management.md
@@ -22,8 +22,7 @@ insights within GitLab:
## Configure cluster cost management
-To get started with cluster cost management, you need [Maintainer](../permissions.md)
-permissions in a project or group.
+To get started with cluster cost management, you need the [Maintainer role](../permissions.md) in a project or group.
1. Clone the [`kubecost-cost-model`](https://gitlab.com/gitlab-examples/kubecost-cost-model/)
example repository, which contains minor modifications to the upstream Kubecost
diff --git a/doc/user/clusters/environments.md b/doc/user/clusters/environments.md
index 72bc7b398dc..71eb08ee640 100644
--- a/doc/user/clusters/environments.md
+++ b/doc/user/clusters/environments.md
@@ -6,8 +6,8 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Cluster Environments (DEPRECATED) **(PREMIUM)**
-> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/13392) in [GitLab Premium](https://about.gitlab.com/pricing/) 12.3 for group-level clusters.
-> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/14809) in [GitLab Premium](https://about.gitlab.com/pricing/) 12.4 for instance-level clusters.
+> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/13392) in GitLab 12.3 for group-level clusters.
+> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/14809) in GitLab 12.4 for instance-level clusters.
> - [Deprecated](https://gitlab.com/groups/gitlab-org/configure/-/epics/8) in GitLab 14.5.
WARNING:
diff --git a/doc/user/clusters/migrating_from_gma_to_project_template.md b/doc/user/clusters/migrating_from_gma_to_project_template.md
index 2da058fb5bc..20c4408d57e 100644
--- a/doc/user/clusters/migrating_from_gma_to_project_template.md
+++ b/doc/user/clusters/migrating_from_gma_to_project_template.md
@@ -4,7 +4,7 @@ group: Configure
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
---
-# Migrate from GitLab Managed Apps to Cluster Management Projects
+# Migrate from GitLab Managed Apps to Cluster Management Projects **(FREE)**
The [GitLab Managed Apps](applications.md) were deprecated in GitLab 14.0
in favor of [Cluster Management Projects](management_project.md).
diff --git a/spec/frontend/__helpers__/experimentation_helper.js b/spec/frontend/__helpers__/experimentation_helper.js
index e0156226acc..d5044be88d7 100644
--- a/spec/frontend/__helpers__/experimentation_helper.js
+++ b/spec/frontend/__helpers__/experimentation_helper.js
@@ -25,7 +25,7 @@ export function stubExperiments(experiments = {}) {
window.gon.experiment = window.gon.experiment || {};
// Preferred
window.gl = window.gl || {};
- window.gl.experiments = window.gl.experiemnts || {};
+ window.gl.experiments = window.gl.experiments || {};
Object.entries(experiments).forEach(([name, variant]) => {
const experimentData = { experiment: name, variant };
diff --git a/spec/graphql/resolvers/users/participants_resolver_spec.rb b/spec/graphql/resolvers/users/participants_resolver_spec.rb
index 77e3b6d5912..3f04d157410 100644
--- a/spec/graphql/resolvers/users/participants_resolver_spec.rb
+++ b/spec/graphql/resolvers/users/participants_resolver_spec.rb
@@ -13,6 +13,7 @@ RSpec.describe Resolvers::Users::ParticipantsResolver do
let_it_be(:note) do
create(
:note,
+ :system,
:confidential,
project: project,
noteable: issue,
@@ -20,6 +21,8 @@ RSpec.describe Resolvers::Users::ParticipantsResolver do
)
end
+ let_it_be(:note_metadata) { create(:system_note_metadata, note: note) }
+
subject(:resolved_items) { resolve(described_class, args: {}, ctx: { current_user: current_user }, obj: issue)&.items }
before do
@@ -50,17 +53,30 @@ RSpec.describe Resolvers::Users::ParticipantsResolver do
is_expected.to match_array([issue.author, note.author])
end
- it 'does not execute N+1 for project relation' do
- query = -> { resolve(described_class, args: {}, ctx: { current_user: current_user }, obj: issue)&.items }
+ context 'N+1 queries' do
+ let(:query) { -> { resolve(described_class, args: {}, ctx: { current_user: current_user }, obj: issue)&.items } }
+
+ before do
+ # warm-up
+ query.call
+ end
+
+ it 'does not execute N+1 for project relation' do
+ control_count = ActiveRecord::QueryRecorder.new { query.call }
+
+ create(:note, :confidential, project: project, noteable: issue, author: create(:user))
- # warm-up
- query.call
+ expect { query.call }.not_to exceed_query_limit(control_count)
+ end
- control_count = ActiveRecord::QueryRecorder.new { query.call }
+ it 'does not execute N+1 for system note metadata relation' do
+ control_count = ActiveRecord::QueryRecorder.new { query.call }
- create(:note, :confidential, project: project, noteable: issue, author: create(:user))
+ new_note = create(:note, :system, project: project, noteable: issue, author: create(:user))
+ create(:system_note_metadata, note: new_note)
- expect { query.call }.not_to exceed_query_limit(control_count)
+ expect { query.call }.not_to exceed_query_limit(control_count)
+ end
end
end
end
diff --git a/spec/migrations/20210713042000_fix_ci_sources_pipelines_index_names_spec.rb b/spec/migrations/20210713042000_fix_ci_sources_pipelines_index_names_spec.rb
new file mode 100644
index 00000000000..adec1e05533
--- /dev/null
+++ b/spec/migrations/20210713042000_fix_ci_sources_pipelines_index_names_spec.rb
@@ -0,0 +1,67 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require_migration!
+
+RSpec.describe FixCiSourcesPipelinesIndexNames, :migration do
+ def validate_foreign_keys_and_index!
+ aggregate_failures do
+ expect(subject.foreign_key_exists?(:ci_sources_pipelines, :ci_builds, column: :source_job_id, name: 'fk_be5624bf37')).to be_truthy
+ expect(subject.foreign_key_exists?(:ci_sources_pipelines, :ci_pipelines, column: :pipeline_id, name: 'fk_e1bad85861')).to be_truthy
+ expect(subject.foreign_key_exists?(:ci_sources_pipelines, :ci_pipelines, column: :source_pipeline_id, name: 'fk_d4e29af7d7')).to be_truthy
+ expect(subject.foreign_key_exists?(:ci_sources_pipelines, :projects, column: :source_project_id, name: 'fk_acd9737679')).to be_truthy
+ expect(subject.foreign_key_exists?(:ci_sources_pipelines, :projects, name: 'fk_1e53c97c0a')).to be_truthy
+ expect(subject.foreign_key_exists?(:ci_sources_pipelines, :ci_builds, column: :source_job_id_convert_to_bigint, name: 'fk_be5624bf37_tmp')).to be_falsey
+
+ expect(subject.index_exists_by_name?(:ci_sources_pipelines, described_class::NEW_INDEX_NAME)).to be_truthy
+ expect(subject.index_exists_by_name?(:ci_sources_pipelines, described_class::OLD_INDEX_NAME)).to be_falsey
+ end
+ end
+
+ it 'existing foreign keys and indexes are untouched' do
+ validate_foreign_keys_and_index!
+
+ migrate!
+
+ validate_foreign_keys_and_index!
+ end
+
+ context 'with a legacy (pre-GitLab 10.0) foreign key' do
+ let(:old_foreign_keys) { described_class::OLD_TO_NEW_FOREIGN_KEY_DEFS.keys }
+ let(:new_foreign_keys) { described_class::OLD_TO_NEW_FOREIGN_KEY_DEFS.values.map { |entry| entry[:name] } }
+
+ before do
+ new_foreign_keys.each { |name| subject.remove_foreign_key_if_exists(:ci_sources_pipelines, name: name) }
+
+ # GitLab 9.5.4: https://gitlab.com/gitlab-org/gitlab/-/blob/v9.5.4-ee/db/schema.rb#L2026-2030
+ subject.add_foreign_key(:ci_sources_pipelines, :ci_builds, column: :source_job_id, name: 'fk_3f0c88d7dc', on_delete: :cascade)
+ subject.add_foreign_key(:ci_sources_pipelines, :ci_pipelines, column: :pipeline_id, name: "fk_b8c0fac459", on_delete: :cascade)
+ subject.add_foreign_key(:ci_sources_pipelines, :ci_pipelines, column: :source_pipeline_id, name: "fk_3a3e3cb83a", on_delete: :cascade)
+ subject.add_foreign_key(:ci_sources_pipelines, :projects, column: :source_project_id, name: "fk_8868d0f3e4", on_delete: :cascade)
+ subject.add_foreign_key(:ci_sources_pipelines, :projects, name: "fk_83b4346e48", on_delete: :cascade)
+
+ # https://gitlab.com/gitlab-org/gitlab/-/blob/v9.5.4-ee/db/schema.rb#L443
+ subject.add_index "ci_sources_pipelines", ["source_job_id"], name: described_class::OLD_INDEX_NAME, using: :btree
+ end
+
+ context 'when new index already exists' do
+ it 'corrects foreign key constraints and drops old index' do
+ expect { migrate! }.to change { subject.foreign_key_exists?(:ci_sources_pipelines, :ci_builds, column: :source_job_id, name: 'fk_3f0c88d7dc') }.from(true).to(false)
+
+ validate_foreign_keys_and_index!
+ end
+ end
+
+ context 'when new index does not exist' do
+ before do
+ subject.remove_index("ci_sources_pipelines", name: described_class::NEW_INDEX_NAME)
+ end
+
+ it 'drops the old index' do
+ expect { migrate! }.to change { subject.index_exists_by_name?(:ci_sources_pipelines, described_class::OLD_INDEX_NAME) }.from(true).to(false)
+
+ validate_foreign_keys_and_index!
+ end
+ end
+ end
+end
diff --git a/spec/models/integrations/microsoft_teams_spec.rb b/spec/models/integrations/microsoft_teams_spec.rb
index 033432f31a0..06b285a855c 100644
--- a/spec/models/integrations/microsoft_teams_spec.rb
+++ b/spec/models/integrations/microsoft_teams_spec.rb
@@ -3,6 +3,17 @@
require 'spec_helper'
RSpec.describe Integrations::MicrosoftTeams do
+ it_behaves_like "chat integration", "Microsoft Teams" do
+ let(:client) { ::MicrosoftTeams::Notifier }
+ let(:client_arguments) { webhook_url }
+
+ let(:payload) do
+ {
+ summary: be_present
+ }
+ end
+ end
+
let(:chat_integration) { described_class.new }
let(:webhook_url) { 'https://example.gitlab.com/' }
diff --git a/spec/support/shared_examples/models/chat_integration_shared_examples.rb b/spec/support/shared_examples/models/chat_integration_shared_examples.rb
index 9ae727a87de..e6b270c6188 100644
--- a/spec/support/shared_examples/models/chat_integration_shared_examples.rb
+++ b/spec/support/shared_examples/models/chat_integration_shared_examples.rb
@@ -71,7 +71,7 @@ RSpec.shared_examples "chat integration" do |integration_name|
it "does not call #{integration_name} API" do
result = subject.execute(sample_data)
- expect(result).to be(false)
+ expect(result).to be_falsy
expect(WebMock).not_to have_requested(:post, webhook_url)
end
end
@@ -355,5 +355,11 @@ RSpec.shared_examples "chat integration" do |integration_name|
end
end
end
+
+ context 'deployment events' do
+ let(:sample_data) { Gitlab::DataBuilder::Deployment.build(create(:deployment), Time.now) }
+
+ it_behaves_like "untriggered #{integration_name} integration"
+ end
end
end