summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--.overcommit.yml.example20
-rw-r--r--.rubocop.yml2
-rw-r--r--app/models/concerns/prometheus_adapter.rb2
-rw-r--r--app/models/project.rb2
-rw-r--r--app/models/project_wiki.rb2
-rw-r--r--app/models/repository.rb2
-rw-r--r--changelogs/unreleased/39042-filter-merge-requests-approved-by-user-backend.yml5
-rw-r--r--changelogs/unreleased/refactoring-entities-file-3.yml5
-rw-r--r--doc/administration/gitaly/praefect.md2
-rw-r--r--doc/api/merge_requests.md141
-rw-r--r--doc/development/contributing/style_guides.md4
-rw-r--r--doc/development/testing_guide/frontend_testing.md483
-rw-r--r--doc/user/project/releases/img/releases_count_v12_8.pngbin0 -> 92444 bytes
-rw-r--r--doc/user/project/releases/index.md13
-rw-r--r--doc/user/project/repository/forking_workflow.md4
-rw-r--r--doc/user/project/repository/web_editor.md3
-rw-r--r--doc/user/project/settings/index.md36
-rw-r--r--lib/api/entities.rb25
-rw-r--r--lib/api/entities/email.rb9
-rw-r--r--lib/api/entities/identity.rb9
-rw-r--r--lib/api/entities/membership.rb14
-rw-r--r--lib/api/entities/user_status.rb13
-rw-r--r--lib/api/helpers/internal_helpers.rb2
-rw-r--r--lib/gitlab/gl_repository.rb12
-rw-r--r--lib/gitlab/gl_repository/repo_type.rb43
-rw-r--r--lib/gitlab/repo_path.rb14
-rw-r--r--lib/gitlab/workhorse.rb2
-rw-r--r--spec/lib/gitlab/gl_repository/repo_type_spec.rb22
-rw-r--r--spec/lib/gitlab/gl_repository_spec.rb8
-rw-r--r--spec/models/project_spec.rb4
-rw-r--r--spec/requests/api/internal/base_spec.rb6
-rw-r--r--spec/requests/git_http_spec.rb4
-rw-r--r--spec/requests/jwt_controller_spec.rb22
-rw-r--r--spec/requests/lfs_http_spec.rb8
-rw-r--r--spec/requests/lfs_locks_api_spec.rb14
-rw-r--r--spec/requests/openid_connect_spec.rb4
-rw-r--r--spec/requests/rack_attack_global_spec.rb28
-rw-r--r--spec/requests/user_avatar_spec.rb4
-rw-r--r--spec/services/akismet_service_spec.rb137
-rw-r--r--spec/services/ci/create_pipeline_service/pre_post_stages_spec.rb2
-rw-r--r--spec/support/shared_examples/lib/gitlab/repo_type_shared_examples.rb26
-rw-r--r--tooling/overcommit/Makefile7
-rw-r--r--tooling/overcommit/gems.locked75
-rw-r--r--tooling/overcommit/gems.rb9
45 files changed, 849 insertions, 401 deletions
diff --git a/.gitignore b/.gitignore
index 0513bcf19cc..5cdab272055 100644
--- a/.gitignore
+++ b/.gitignore
@@ -83,6 +83,7 @@ package-lock.json
jsdoc/
**/tmp/rubocop_cache/**
.overcommit.yml
+.overcommit.yml.backup
.projections.json
/qa/.rakeTasks
webpack-dev-server.json
diff --git a/.overcommit.yml.example b/.overcommit.yml.example
index 9cd04825bc2..b957a8bbd2a 100644
--- a/.overcommit.yml.example
+++ b/.overcommit.yml.example
@@ -15,6 +15,13 @@
#
# Uncomment the following lines to make the configuration take effect.
+# Make sure to run `cd tooling/overcommit && make && cd -`
+gemfile: 'tooling/overcommit/gems.rb'
+
+PostCheckout:
+ BundleInstall:
+ enabled: true
+
PreCommit:
AuthorName:
enabled: false
@@ -35,6 +42,19 @@ PreCommit:
# on_warn: fail # Treat all warnings as failures
ScssLint:
enabled: true
+
+CommitMsg:
+ TextWidth:
+ enabled: true
+ min_subject_width: 8 # three 2-letter words with 2 spaces
+ max_subject_width: 72
+ quiet: false
+
+ EmptyMessage:
+ enabled: true
+ required: true
+ description: 'Checking for empty commit message'
+
#PostCheckout:
# ALL: # Special hook name that customizes all hooks of this type
# quiet: true # Change all post-checkout hooks to only display output on failure
diff --git a/.rubocop.yml b/.rubocop.yml
index 860d57d89a0..2e8a7d57bca 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -347,6 +347,8 @@ RSpec/HaveGitlabHttpStatus:
- 'ee/spec/features/**/*'
- 'spec/controllers/*.rb'
- 'ee/spec/controllers/*.rb'
+ - 'spec/requests/*.rb'
+ - 'ee/spec/requests/*.rb'
Style/MultilineWhenThen:
Enabled: false
diff --git a/app/models/concerns/prometheus_adapter.rb b/app/models/concerns/prometheus_adapter.rb
index 99da8b81398..3deb7edba58 100644
--- a/app/models/concerns/prometheus_adapter.rb
+++ b/app/models/concerns/prometheus_adapter.rb
@@ -21,7 +21,7 @@ module PrometheusAdapter
raise NotImplemented
end
- # This is a heavy-weight check if a prometheus is properly configured and accesible from GitLab.
+ # This is a heavy-weight check if a prometheus is properly configured and accessible from GitLab.
# This actually sends a request to an external service and often it could take a long time,
# Please consider using `configured?` instead if the process is running on unicorn/puma threads.
def can_query?
diff --git a/app/models/project.rb b/app/models/project.rb
index c0103190892..a51dd3c1048 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -2207,7 +2207,7 @@ class Project < ApplicationRecord
end
def reference_counter(type: Gitlab::GlRepository::PROJECT)
- Gitlab::ReferenceCounter.new(type.identifier_for_repositorable(self))
+ Gitlab::ReferenceCounter.new(type.identifier_for_container(self))
end
def badges
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index 3bec0c32c2c..1abde5196de 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -65,7 +65,7 @@ class ProjectWiki
# Returns the Gitlab::Git::Wiki object.
def wiki
@wiki ||= begin
- gl_repository = Gitlab::GlRepository::WIKI.identifier_for_repositorable(project)
+ gl_repository = Gitlab::GlRepository::WIKI.identifier_for_container(project)
raw_repository = Gitlab::Git::Repository.new(project.repository_storage, disk_path + '.git', gl_repository, full_path)
create_repo!(raw_repository) unless raw_repository.exists?
diff --git a/app/models/repository.rb b/app/models/repository.rb
index ba0b87b7429..c0d1750fe42 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -1183,7 +1183,7 @@ class Repository
def initialize_raw_repository
Gitlab::Git::Repository.new(project.repository_storage,
disk_path + '.git',
- repo_type.identifier_for_repositorable(project),
+ repo_type.identifier_for_container(project),
project.full_path)
end
end
diff --git a/changelogs/unreleased/39042-filter-merge-requests-approved-by-user-backend.yml b/changelogs/unreleased/39042-filter-merge-requests-approved-by-user-backend.yml
new file mode 100644
index 00000000000..28280a10c15
--- /dev/null
+++ b/changelogs/unreleased/39042-filter-merge-requests-approved-by-user-backend.yml
@@ -0,0 +1,5 @@
+---
+title: Filter merge requests by approvals (API)
+merge_request: 21379
+author:
+type: added
diff --git a/changelogs/unreleased/refactoring-entities-file-3.yml b/changelogs/unreleased/refactoring-entities-file-3.yml
new file mode 100644
index 00000000000..3a33ab90c60
--- /dev/null
+++ b/changelogs/unreleased/refactoring-entities-file-3.yml
@@ -0,0 +1,5 @@
+---
+title: Add separate classes for user related entities for email, membership, status
+merge_request: 23748
+author: Rajendra Kadam
+type: added
diff --git a/doc/administration/gitaly/praefect.md b/doc/administration/gitaly/praefect.md
index ebdfd8f1695..6a1fb0cde2b 100644
--- a/doc/administration/gitaly/praefect.md
+++ b/doc/administration/gitaly/praefect.md
@@ -173,9 +173,11 @@ praefect['virtual_storages'] = {
}
}
+# Replace POSTGRESQL_SERVER below with a real IP/host address of the database.
praefect['database_host'] = 'POSTGRESQL_SERVER'
praefect['database_port'] = 5432
praefect['database_user'] = 'praefect'
+# Replace PRAEFECT_SQL_PASSWORD below with a real password of the database.
praefect['database_password'] = 'PRAEFECT_SQL_PASSWORD'
praefect['database_dbname'] = 'praefect_production'
diff --git a/doc/api/merge_requests.md b/doc/api/merge_requests.md
index 3a00e862094..127a510aae6 100644
--- a/doc/api/merge_requests.md
+++ b/doc/api/merge_requests.md
@@ -37,29 +37,30 @@ GET /merge_requests?search=foo&in=title
Parameters:
-| Attribute | Type | Required | Description |
-| ------------------- | -------- | -------- | ---------------------------------------------------------------------------------------------------------------------- |
-| `state` | string | no | Return all merge requests or just those that are `opened`, `closed`, `locked`, or `merged` |
-| `order_by` | string | no | Return requests ordered by `created_at` or `updated_at` fields. Default is `created_at` |
-| `sort` | string | no | Return requests sorted in `asc` or `desc` order. Default is `desc` |
-| `milestone` | string | no | Return merge requests for a specific milestone. `None` returns merge requests with no milestone. `Any` returns merge requests that have an assigned milestone. |
-| `view` | string | no | If `simple`, returns the `iid`, URL, title, description, and basic state of merge request |
-| `labels` | string | no | Return merge requests matching a comma separated list of labels. `None` lists all merge requests with no labels. `Any` lists all merge requests with at least one label. `No+Label` (Deprecated) lists all merge requests with no labels. Predefined names are case-insensitive. |
-| `with_labels_details` | Boolean | no | If `true`, response will return more details for each label in labels field: `:name`, `:color`, `:description`, `:description_html`, `:text_color`. Default is `false`. Introduced in [GitLab 12.7](https://gitlab.com/gitlab-org/gitlab/merge_requests/21413) |
-| `created_after` | datetime | no | Return merge requests created on or after the given time |
-| `created_before` | datetime | no | Return merge requests created on or before the given time |
-| `updated_after` | datetime | no | Return merge requests updated on or after the given time |
-| `updated_before` | datetime | no | Return merge requests updated on or before the given time |
-| `scope` | string | no | Return merge requests for the given scope: `created_by_me`, `assigned_to_me` or `all`. Defaults to `created_by_me`<br> For versions before 11.0, use the now deprecated `created-by-me` or `assigned-to-me` scopes instead. |
-| `author_id` | integer | no | Returns merge requests created by the given user `id`. Combine with `scope=all` or `scope=assigned_to_me` |
-| `assignee_id` | integer | no | Returns merge requests assigned to the given user `id`. `None` returns unassigned merge requests. `Any` returns merge requests with an assignee. |
-| `approver_ids` **(STARTER)** | integer array | no | Returns merge requests which have specified all the users with the given `id`s as individual approvers. `None` returns merge requests without approvers. `Any` returns merge requests with an approver. |
-| `my_reaction_emoji` | string | no | Return merge requests reacted by the authenticated user by the given `emoji`. `None` returns issues not given a reaction. `Any` returns issues given at least one reaction. _([Introduced][ce-14016] in GitLab 10.0)_ |
-| `source_branch` | string | no | Return merge requests with the given source branch |
-| `target_branch` | string | no | Return merge requests with the given target branch |
-| `search` | string | no | Search merge requests against their `title` and `description` |
-| `in` | string | no | Modify the scope of the `search` attribute. `title`, `description`, or a string joining them with comma. Default is `title,description` |
-| `wip` | string | no | Filter merge requests against their `wip` status. `yes` to return *only* WIP merge requests, `no` to return *non* WIP merge requests |
+| Attribute | Type | Required | Description |
+| ------------------------------- | -------------- | -------- | ---------------------------------------------------------------------------------------------------------------------- |
+| `state` | string | no | Return all merge requests or just those that are `opened`, `closed`, `locked`, or `merged` |
+| `order_by` | string | no | Return requests ordered by `created_at` or `updated_at` fields. Default is `created_at` |
+| `sort` | string | no | Return requests sorted in `asc` or `desc` order. Default is `desc` |
+| `milestone` | string | no | Return merge requests for a specific milestone. `None` returns merge requests with no milestone. `Any` returns merge requests that have an assigned milestone. |
+| `view` | string | no | If `simple`, returns the `iid`, URL, title, description, and basic state of merge request |
+| `labels` | string | no | Return merge requests matching a comma separated list of labels. `None` lists all merge requests with no labels. `Any` lists all merge requests with at least one label. `No+Label` (Deprecated) lists all merge requests with no labels. Predefined names are case-insensitive. |
+| `with_labels_details` | Boolean | no | If `true`, response will return more details for each label in labels field: `:name`, `:color`, `:description`, `:description_html`, `:text_color`. Default is `false`. Introduced in [GitLab 12.7](https://gitlab.com/gitlab-org/gitlab/merge_requests/21413) |
+| `created_after` | datetime | no | Return merge requests created on or after the given time |
+| `created_before` | datetime | no | Return merge requests created on or before the given time |
+| `updated_after` | datetime | no | Return merge requests updated on or after the given time |
+| `updated_before` | datetime | no | Return merge requests updated on or before the given time |
+| `scope` | string | no | Return merge requests for the given scope: `created_by_me`, `assigned_to_me` or `all`. Defaults to `created_by_me`<br> For versions before 11.0, use the now deprecated `created-by-me` or `assigned-to-me` scopes instead. |
+| `author_id` | integer | no | Returns merge requests created by the given user `id`. Combine with `scope=all` or `scope=assigned_to_me` |
+| `assignee_id` | integer | no | Returns merge requests assigned to the given user `id`. `None` returns unassigned merge requests. `Any` returns merge requests with an assignee. |
+| `approver_ids` **(STARTER)** | integer array | no | Returns merge requests which have specified all the users with the given `id`s as individual approvers. `None` returns merge requests without approvers. `Any` returns merge requests with an approver. |
+| `approved_by_ids` **(STARTER)** | integer array | no | Returns merge requests which have been approved by all the users with the given `id`s (Max: 5). `None` returns merge requests with no approvals. `Any` returns merge requests with an approval. |
+| `my_reaction_emoji` | string | no | Return merge requests reacted by the authenticated user by the given `emoji`. `None` returns issues not given a reaction. `Any` returns issues given at least one reaction. _([Introduced][ce-14016] in GitLab 10.0)_ |
+| `source_branch` | string | no | Return merge requests with the given source branch |
+| `target_branch` | string | no | Return merge requests with the given target branch |
+| `search` | string | no | Search merge requests against their `title` and `description` |
+| `in` | string | no | Modify the scope of the `search` attribute. `title`, `description`, or a string joining them with comma. Default is `title,description` |
+| `wip` | string | no | Filter merge requests against their `wip` status. `yes` to return *only* WIP merge requests, `no` to return *non* WIP merge requests |
NOTE: **Note:**
[Starting in GitLab 12.8](https://gitlab.com/gitlab-org/gitlab/issues/29984),
@@ -210,30 +211,31 @@ will be the same. In the case of a merge request from a fork,
Parameters:
-| Attribute | Type | Required | Description |
-| ------------------- | -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------ |
-| `id` | integer | yes | The ID of a project |
-| `iids[]` | integer array | no | Return the request having the given `iid` |
-| `state` | string | no | Return all merge requests or just those that are `opened`, `closed`, `locked`, or `merged` |
-| `order_by` | string | no | Return requests ordered by `created_at` or `updated_at` fields. Default is `created_at` |
-| `sort` | string | no | Return requests sorted in `asc` or `desc` order. Default is `desc` |
-| `milestone` | string | no | Return merge requests for a specific milestone. `None` returns merge requests with no milestone. `Any` returns merge requests that have an assigned milestone. |
-| `view` | string | no | If `simple`, returns the `iid`, URL, title, description, and basic state of merge request |
-| `labels` | string | no | Return merge requests matching a comma separated list of labels. `None` lists all merge requests with no labels. `Any` lists all merge requests with at least one label. `No+Label` (Deprecated) lists all merge requests with no labels. Predefined names are case-insensitive. |
-| `with_labels_details` | Boolean | no | If `true`, response will return more details for each label in labels field: `:name`, `:color`, `:description`, `:description_html`, `:text_color`. Default is `false`. Introduced in [GitLab 12.7](https://gitlab.com/gitlab-org/gitlab/merge_requests/21413) |
-| `created_after` | datetime | no | Return merge requests created on or after the given time |
-| `created_before` | datetime | no | Return merge requests created on or before the given time |
-| `updated_after` | datetime | no | Return merge requests updated on or after the given time |
-| `updated_before` | datetime | no | Return merge requests updated on or before the given time |
-| `scope` | string | no | Return merge requests for the given scope: `created_by_me`, `assigned_to_me` or `all`.<br> For versions before 11.0, use the now deprecated `created-by-me` or `assigned-to-me` scopes instead.<br> _([Introduced][ce-13060] in GitLab 9.5. [Changed to snake_case][ce-18935] in GitLab 11.0)_ |
-| `author_id` | integer | no | Returns merge requests created by the given user `id` _([Introduced][ce-13060] in GitLab 9.5)_ |
-| `assignee_id` | integer | no | Returns merge requests assigned to the given user `id`. `None` returns unassigned merge requests. `Any` returns merge requests with an assignee. _([Introduced][ce-13060] in GitLab 9.5)_ |
-| `approver_ids` **(STARTER)** | integer array | no | Returns merge requests which have specified all the users with the given `id`s as individual approvers. `None` returns merge requests without approvers. `Any` returns merge requests with an approver. |
-| `my_reaction_emoji` | string | no | Return merge requests reacted by the authenticated user by the given `emoji`. `None` returns issues not given a reaction. `Any` returns issues given at least one reaction. _([Introduced][ce-14016] in GitLab 10.0)_ |
-| `source_branch` | string | no | Return merge requests with the given source branch |
-| `target_branch` | string | no | Return merge requests with the given target branch |
-| `search` | string | no | Search merge requests against their `title` and `description` |
-| `wip` | string | no | Filter merge requests against their `wip` status. `yes` to return *only* WIP merge requests, `no` to return *non* WIP merge requests |
+| Attribute | Type | Required | Description |
+| ------------------------------- | -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------ |
+| `id` | integer | yes | The ID of a project |
+| `iids[]` | integer array | no | Return the request having the given `iid` |
+| `state` | string | no | Return all merge requests or just those that are `opened`, `closed`, `locked`, or `merged` |
+| `order_by` | string | no | Return requests ordered by `created_at` or `updated_at` fields. Default is `created_at` |
+| `sort` | string | no | Return requests sorted in `asc` or `desc` order. Default is `desc` |
+| `milestone` | string | no | Return merge requests for a specific milestone. `None` returns merge requests with no milestone. `Any` returns merge requests that have an assigned milestone. |
+| `view` | string | no | If `simple`, returns the `iid`, URL, title, description, and basic state of merge request |
+| `labels` | string | no | Return merge requests matching a comma separated list of labels. `None` lists all merge requests with no labels. `Any` lists all merge requests with at least one label. `No+Label` (Deprecated) lists all merge requests with no labels. Predefined names are case-insensitive. |
+| `with_labels_details` | Boolean | no | If `true`, response will return more details for each label in labels field: `:name`, `:color`, `:description`, `:description_html`, `:text_color`. Default is `false`. Introduced in [GitLab 12.7](https://gitlab.com/gitlab-org/gitlab/merge_requests/21413) |
+| `created_after` | datetime | no | Return merge requests created on or after the given time |
+| `created_before` | datetime | no | Return merge requests created on or before the given time |
+| `updated_after` | datetime | no | Return merge requests updated on or after the given time |
+| `updated_before` | datetime | no | Return merge requests updated on or before the given time |
+| `scope` | string | no | Return merge requests for the given scope: `created_by_me`, `assigned_to_me` or `all`.<br> For versions before 11.0, use the now deprecated `created-by-me` or `assigned-to-me` scopes instead.<br> _([Introduced][ce-13060] in GitLab 9.5. [Changed to snake_case][ce-18935] in GitLab 11.0)_ |
+| `author_id` | integer | no | Returns merge requests created by the given user `id` _([Introduced][ce-13060] in GitLab 9.5)_ |
+| `assignee_id` | integer | no | Returns merge requests assigned to the given user `id`. `None` returns unassigned merge requests. `Any` returns merge requests with an assignee. _([Introduced][ce-13060] in GitLab 9.5)_ |
+| `approver_ids` **(STARTER)** | integer array | no | Returns merge requests which have specified all the users with the given `id`s as individual approvers. `None` returns merge requests without approvers. `Any` returns merge requests with an approver. |
+| `approved_by_ids` **(STARTER)** | integer array | no | Returns merge requests which have been approved by all the users with the given `id`s (Max: 5). `None` returns merge requests with no approvals. `Any` returns merge requests with an approval. |
+| `my_reaction_emoji` | string | no | Return merge requests reacted by the authenticated user by the given `emoji`. `None` returns issues not given a reaction. `Any` returns issues given at least one reaction. _([Introduced][ce-14016] in GitLab 10.0)_ |
+| `source_branch` | string | no | Return merge requests with the given source branch |
+| `target_branch` | string | no | Return merge requests with the given target branch |
+| `search` | string | no | Search merge requests against their `title` and `description` |
+| `wip` | string | no | Filter merge requests against their `wip` status. `yes` to return *only* WIP merge requests, `no` to return *non* WIP merge requests |
```json
[
@@ -372,28 +374,29 @@ GET /groups/:id/merge_requests?my_reaction_emoji=star
Parameters:
-| Attribute | Type | Required | Description |
-| ------------------- | -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------ |
-| `id` | integer | yes | The ID of a group |
-| `state` | string | no | Return all merge requests or just those that are `opened`, `closed`, `locked`, or `merged` |
-| `order_by` | string | no | Return merge requests ordered by `created_at` or `updated_at` fields. Default is `created_at` |
-| `sort` | string | no | Return merge requests sorted in `asc` or `desc` order. Default is `desc` |
-| `milestone` | string | no | Return merge requests for a specific milestone. `None` returns merge requests with no milestone. `Any` returns merge requests that have an assigned milestone. |
-| `view` | string | no | If `simple`, returns the `iid`, URL, title, description, and basic state of merge request |
-| `labels` | string | no | Return merge requests matching a comma separated list of labels. `None` lists all merge requests with no labels. `Any` lists all merge requests with at least one label. `No+Label` (Deprecated) lists all merge requests with no labels. Predefined names are case-insensitive. |
-| `with_labels_details` | Boolean | no | If `true`, response will return more details for each label in labels field: `:name`, `:color`, `:description`, `:description_html`, `:text_color`. Default is `false`. Introduced in [GitLab 12.7](https://gitlab.com/gitlab-org/gitlab/merge_requests/21413)|
-| `created_after` | datetime | no | Return merge requests created on or after the given time |
-| `created_before` | datetime | no | Return merge requests created on or before the given time |
-| `updated_after` | datetime | no | Return merge requests updated on or after the given time |
-| `updated_before` | datetime | no | Return merge requests updated on or before the given time |
-| `scope` | string | no | Return merge requests for the given scope: `created_by_me`, `assigned_to_me` or `all`.<br> |
-| `author_id` | integer | no | Returns merge requests created by the given user `id` _([Introduced][ce-13060] in GitLab 9.5)_ |
-| `assignee_id` | integer | no | Returns merge requests assigned to the given user `id`. `None` returns unassigned merge requests. `Any` returns merge requests with an assignee. _([Introduced][ce-13060] in GitLab 9.5)_ |
-| `approver_ids` **(STARTER)** | integer array | no | Returns merge requests which have specified all the users with the given `id`s as individual approvers. `None` returns merge requests without approvers. `Any` returns merge requests with an approver. |
-| `my_reaction_emoji` | string | no | Return merge requests reacted by the authenticated user by the given `emoji`. `None` returns issues not given a reaction. `Any` returns issues given at least one reaction. _([Introduced][ce-14016] in GitLab 10.0)_ |
-| `source_branch` | string | no | Return merge requests with the given source branch |
-| `target_branch` | string | no | Return merge requests with the given target branch |
-| `search` | string | no | Search merge requests against their `title` and `description` |
+| Attribute | Type | Required | Description |
+| ------------------------------- | -------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------ |
+| `id` | integer | yes | The ID of a group |
+| `state` | string | no | Return all merge requests or just those that are `opened`, `closed`, `locked`, or `merged` |
+| `order_by` | string | no | Return merge requests ordered by `created_at` or `updated_at` fields. Default is `created_at` |
+| `sort` | string | no | Return merge requests sorted in `asc` or `desc` order. Default is `desc` |
+| `milestone` | string | no | Return merge requests for a specific milestone. `None` returns merge requests with no milestone. `Any` returns merge requests that have an assigned milestone. |
+| `view` | string | no | If `simple`, returns the `iid`, URL, title, description, and basic state of merge request |
+| `labels` | string | no | Return merge requests matching a comma separated list of labels. `None` lists all merge requests with no labels. `Any` lists all merge requests with at least one label. `No+Label` (Deprecated) lists all merge requests with no labels. Predefined names are case-insensitive. |
+| `with_labels_details` | Boolean | no | If `true`, response will return more details for each label in labels field: `:name`, `:color`, `:description`, `:description_html`, `:text_color`. Default is `false`. Introduced in [GitLab 12.7](https://gitlab.com/gitlab-org/gitlab/merge_requests/21413)|
+| `created_after` | datetime | no | Return merge requests created on or after the given time |
+| `created_before` | datetime | no | Return merge requests created on or before the given time |
+| `updated_after` | datetime | no | Return merge requests updated on or after the given time |
+| `updated_before` | datetime | no | Return merge requests updated on or before the given time |
+| `scope` | string | no | Return merge requests for the given scope: `created_by_me`, `assigned_to_me` or `all`.<br> |
+| `author_id` | integer | no | Returns merge requests created by the given user `id` _([Introduced][ce-13060] in GitLab 9.5)_ |
+| `assignee_id` | integer | no | Returns merge requests assigned to the given user `id`. `None` returns unassigned merge requests. `Any` returns merge requests with an assignee. _([Introduced][ce-13060] in GitLab 9.5)_ |
+| `approver_ids` **(STARTER)** | integer array | no | Returns merge requests which have specified all the users with the given `id`s as individual approvers. `None` returns merge requests without approvers. `Any` returns merge requests with an approver. |
+| `approved_by_ids` **(STARTER)** | integer array | no | Returns merge requests which have been approved by all the users with the given `id`s (Max: 5). `None` returns merge requests with no approvals. `Any` returns merge requests with an approval. |
+| `my_reaction_emoji` | string | no | Return merge requests reacted by the authenticated user by the given `emoji`. `None` returns issues not given a reaction. `Any` returns issues given at least one reaction. _([Introduced][ce-14016] in GitLab 10.0)_ |
+| `source_branch` | string | no | Return merge requests with the given source branch |
+| `target_branch` | string | no | Return merge requests with the given target branch |
+| `search` | string | no | Search merge requests against their `title` and `description` |
```json
[
diff --git a/doc/development/contributing/style_guides.md b/doc/development/contributing/style_guides.md
index d53675cc716..33c872cbb93 100644
--- a/doc/development/contributing/style_guides.md
+++ b/doc/development/contributing/style_guides.md
@@ -30,7 +30,9 @@
This is also the style used by linting tools such as
[RuboCop](https://github.com/rubocop-hq/rubocop) and [Hound CI](https://houndci.com).
You can run RuboCop by hand or install a tool like [Overcommit](https://github.com/sds/overcommit) to run it for you.
-Overcommit will automatically run the configured checks (like Rubocop) on every modified file before commit. You can use the example overcommit configuration found in `.overcommit.yml.example` as a quickstart.
+
+Overcommit will automatically run the configured checks (like Rubocop) on every modified file before commit.
+You can use the example overcommit configuration found in `.overcommit.yml.example` as a quickstart.
This saves you time as you don't have to wait for the same errors to be detected by the CI.
---
diff --git a/doc/development/testing_guide/frontend_testing.md b/doc/development/testing_guide/frontend_testing.md
index 56b059063e0..e2b29136524 100644
--- a/doc/development/testing_guide/frontend_testing.md
+++ b/doc/development/testing_guide/frontend_testing.md
@@ -1,7 +1,7 @@
# Frontend testing standards and style guidelines
There are two types of test suites you'll encounter while developing frontend code
-at GitLab. We use Karma and Jasmine for JavaScript unit and integration testing,
+at GitLab. We use Karma with Jasmine and Jest for JavaScript unit and integration testing,
and RSpec feature tests with Capybara for e2e (end-to-end) integration testing.
Unit and feature tests need to be written for all new features.
@@ -13,6 +13,10 @@ in the future.
See the [Testing Standards and Style Guidelines](index.md) page for more
information on general testing practices at GitLab.
+## Vue.js testing
+
+If you are looking for a guide on Vue component testing, you can jump right away to this [section][vue-test].
+
## Jest
We have started to migrate frontend tests to the [Jest](https://jestjs.io) testing framework (see also the corresponding
@@ -20,6 +24,25 @@ We have started to migrate frontend tests to the [Jest](https://jestjs.io) testi
Jest tests can be found in `/spec/frontend` and `/ee/spec/frontend` in EE.
+> **Note:**
+>
+> Most examples have a Jest and Karma example. See the Karma examples only as explanation to what's going on in the code, should you stumble over some usescases during your discovery. The Jest examples are the one you should follow.
+
+## Karma test suite
+
+While GitLab is switching over to [Jest][jest] you'll still find Karma tests in our application. [Karma][karma] is a test runner which uses [Jasmine] as its test
+framework. Jest also uses Jasmine as foundation, that's why it's looking quite similar.
+
+Karma tests live in `spec/javascripts/` and `/ee/spec/javascripts` in EE.
+
+`app/assets/javascripts/behaviors/autosize.js`
+might have a corresponding `spec/javascripts/behaviors/autosize_spec.js` file.
+
+Keep in mind that in a CI environment, these tests are run in a headless
+browser and you will not have access to certain APIs, such as
+[`Notification`](https://developer.mozilla.org/en-US/docs/Web/API/notification),
+which have to be stubbed.
+
### When should I use Jest over Karma?
If you need to update an existing Karma test file (found in `spec/javascripts`), you do not
@@ -88,98 +111,98 @@ describe('Component', () => {
Remember that the performance of each test depends on the environment.
-### Manual module mocks
+## What and how to test
-Jest supports [manual module mocks](https://jestjs.io/docs/en/manual-mocks) by placing a mock in a `__mocks__/` directory next to the source module. **Don't do this.** We want to keep all of our test-related code in one place (the `spec/` folder), and the logic that Jest uses to apply mocks from `__mocks__/` is rather inconsistent.
+Before jumping into more gritty details about Jest-specific workflows like mocks and spies, we should briefly cover what to test with Jest.
-Instead, our test runner detects manual mocks from `spec/frontend/mocks/`. Any mock placed here is automatically picked up and injected whenever you import its source module.
+### Don't test the library
-- Files in `spec/frontend/mocks/ce` will mock the corresponding CE module from `app/assets/javascripts`, mirroring the source module's path.
- - Example: `spec/frontend/mocks/ce/lib/utils/axios_utils` will mock the module `~/lib/utils/axios_utils`.
-- Files in `spec/frontend/mocks/node` will mock NPM packages of the same name or path.
-- We don't support mocking EE modules yet.
+Libraries are an integral part of any JavaScript developer's life. The general advice would be to not test library internals, but expect that the library knows what it's supposed to do and has test coverage on its own.
+A general example could be something like this
-If a mock is found for which a source module doesn't exist, the test suite will fail. 'Virtual' mocks, or mocks that don't have a 1-to-1 association with a source module, are not supported yet.
-
-#### Writing a mock
-
-Create a JS module in the appropriate place in `spec/frontend/mocks/`. That's it. It will automatically mock its source package in all tests.
+```javascript
+import { convertToFahrenheit } from 'temperatureLibrary'
-Make sure that your mock's export has the same format as the mocked module. So, if you're mocking a CommonJS module, you'll need to use `module.exports` instead of the ES6 `export`.
+function getFahrenheit(celsius) {
+ return convertToFahrenheit(celsius)
+}
+```
-It might be useful for a mock to expose a property that indicates if the mock was loaded. This way, tests can assert the presence of a mock without calling any logic and causing side-effects. The `~/lib/utils/axios_utils` module mock has such a property, `isMock`, that is `true` in the mock and undefined in the original class. Jest's mock functions also have a `mock` property that you can test.
+It does not make sense to test our `getFahrenheit` function because underneath it does nothing else but invoking the library function, and we can expect that one is working as intended. (Simplified, I know)
-#### Bypassing mocks
+Let's take a short look into Vue land. Vue is a critical part of the GitLab JavaScript codebase. When writing specs for Vue components, a common gotcha is to actually end up testing Vue provided functionality, because it appears to be the easiest thing to test. Here's an example taken from our codebase.
-If you ever need to import the original module in your tests, use [`jest.requireActual()`](https://jestjs.io/docs/en/jest-object#jestrequireactualmodulename) (or `jest.requireActual().default` for the default export). The `jest.mock()` and `jest.unmock()` won't have an effect on modules that have a manual mock, because mocks are imported and cached before any tests are run.
+```javascript
+// Component
+{
+ computed: {
+ hasMetricTypes() {
+ return this.metricTypes.length;
+ },
+}
+```
-#### Keep mocks light
+and here's the corresponding spec
-Global mocks introduce magic and can affect how modules are imported in your tests. Try to keep them as light as possible and dependency-free. A global mock should be useful for any unit test. For example, the `axios_utils` and `jquery` module mocks throw an error when an HTTP request is attempted, since this is useful behaviour in &gt;99% of tests.
+```javascript
+ describe('computed', () => {
+ describe('hasMetricTypes', () => {
+ it('returns true if metricTypes exist', () => {
+ factory({ metricTypes });
+ expect(wrapper.vm.hasMetricTypes).toBe(2);
+ });
+
+ it('returns true if no metricTypes exist', () => {
+ factory();
+ expect(wrapper.vm.hasMetricTypes).toBe(0);
+ });
+ });
+});
+```
-When in doubt, construct mocks in your test file using [`jest.mock()`](https://jestjs.io/docs/en/jest-object#jestmockmodulename-factory-options), [`jest.spyOn()`](https://jestjs.io/docs/en/jest-object#jestspyonobject-methodname), etc.
+Testing the `hasMetricTypes` computed prop would seem like a given, but to test if the computed property is returning the length of `metricTypes`, is testing the Vue library itself. There is no value in this, besides it adding to the test suite. Better is to test it in the way the user interacts with it. Probably through the template.
-### Data-driven tests
+Keep an eye out for these kinds of tests, as they just make updating logic more fragile and tedious than it needs to be. This is also true for other libraries.
-Similar to [RSpec's parameterized tests](best_practices.md#table-based--parameterized-tests),
-Jest supports data-driven tests for:
+Some more examples can be found further down [below](#unit-testing-guidelines)
-- Individual tests using [`test.each`](https://jestjs.io/docs/en/api#testeachtable-name-fn-timeout) (aliased to `it.each`).
-- Groups of tests using [`describe.each`](https://jestjs.io/docs/en/api#describeeachtable-name-fn-timeout).
+### Don't test your mock
-These can be useful for reducing repetition within tests. Each option can take an array of
-data values or a tagged template literal.
+Another common gotcha is that the specs end up verifying the mock is working. If you are using mocks, the mock should support the test, but not be the target of the test.
-For example:
+**Bad:**
```javascript
-// function to test
-const icon = status => status ? 'pipeline-passed' : 'pipeline-failed'
-const message = status => status ? 'pipeline-passed' : 'pipeline-failed'
+const spy = jest.spyOn(idGenerator, 'create')
+spy.mockImplementation = () = '1234'
-// test with array block
-it.each([
- [false, 'pipeline-failed'],
- [true, 'pipeline-passed']
-])('icon with %s will return %s',
- (status, icon) => {
- expect(renderPipeline(status)).toEqual(icon)
- }
-);
+expect(idGenerator.create()).toBe('1234')
+```
-// test suite with tagged template literal block
-describe.each`
- status | icon | message
- ${false} | ${'pipeline-failed'} | ${'Pipeline failed - boo-urns'}
- ${true} | ${'pipeline-passed'} | ${'Pipeline succeeded - win!'}
-`('pipeline component', ({ status, icon, message }) => {
- it(`returns icon ${icon} with status ${status}`, () => {
- expect(icon(status)).toEqual(message)
- })
+**Good:**
- it(`returns message ${message} with status ${status}`, () => {
- expect(message(status)).toEqual(message)
- })
-});
+```javascript
+const spy = jest.spyOn(idGenerator, 'create')
+spy.mockImplementation = () = '1234'
+
+// Actually focusing on the logic of your component and just leverage the controllable mocks output
+expect(wrapper.find('div').html()).toBe('<div id="1234">...</div>')
```
-## Karma test suite
+### Follow the user
-GitLab uses the [Karma][karma] test runner with [Jasmine] as its test
-framework for our JavaScript unit and integration tests.
+The line between unit and integration tests can be quite blurry in a component heavy world. The most important guideline to give is the following:
-JavaScript tests live in `spec/javascripts/`, matching the folder structure
-of `app/assets/javascripts/`: `app/assets/javascripts/behaviors/autosize.js`
-has a corresponding `spec/javascripts/behaviors/autosize_spec.js` file.
+- Write clean unit tests if there is actual value in testing a complex piece of logic in isolation to prevent it from breaking in the future
+- Otherwise, try to write your specs as close to the user's flow as possible
-Keep in mind that in a CI environment, these tests are run in a headless
-browser and you will not have access to certain APIs, such as
-[`Notification`](https://developer.mozilla.org/en-US/docs/Web/API/notification),
-which will have to be stubbed.
+For example, it's better to use the generated markup to trigger a button click and validate the markup changed accordingly than to call a method manually and verify data structures or computed properties. There's always the chance of accidentally breaking the user flow, while the tests pass and provide a false sense of security.
-### Best practices
+## Common practices
-#### Naming unit tests
+Following you'll find some general common practices you will find as part of our testsuite. Should you stumble over something not following this guide, ideally fix it right away. 🎉
+
+### Naming unit tests
When writing describe test blocks to test specific functions/methods,
please use the method name as the describe block name.
@@ -207,10 +230,29 @@ describe('.methodName', () => {
});
```
-#### Testing promises
+### Testing promises
-When testing Promises you should always make sure that the test is asynchronous and rejections are handled.
-Your Promise chain should therefore end with a call of the `done` callback and `done.fail` in case an error occurred.
+When testing Promises you should always make sure that the test is asynchronous and rejections are handled. It's now possible to use the `async/await` syntax in the test suite:
+
+```javascript
+it('tests a promise', async () => {
+ const users = await fetchUsers()
+ expect(users.length).toBe(42)
+});
+
+it('tests a promise rejection', async () => {
+ expect.assertions(1);
+ try {
+ await user.getUserName(1);
+ } catch (e) {
+ expect(e).toEqual({
+ error: 'User with 1 not found.',
+ });
+ }
+});
+```
+
+You can also work with Promise chains. In this case, you can make use of the `done` callback and `done.fail` in case an error occurred. Following are some examples:
```javascript
// Good
@@ -270,62 +312,58 @@ it('tests a promise rejection', done => {
});
```
-#### Stubbing and Mocking
+### Manipulating Time
-Jasmine provides useful helpers `spyOn`, `spyOnProperty`, `jasmine.createSpy`,
-and `jasmine.createSpyObject` to facilitate replacing methods with dummy
-placeholders, and recalling when they are called and the arguments that are
-passed to them. These tools should be used liberally, to test for expected
-behavior, to mock responses, and to block unwanted side effects (such as a
-method that would generate a network request or alter `window.location`). The
-documentation for these methods can be found in the [Jasmine introduction page](https://jasmine.github.io/2.0/introduction.html#section-Spies).
+Sometimes we have to test time-sensitive code. For example, recurring events that run every X amount of seconds or similar. Here you'll find some strategies to deal with that:
-Sometimes you may need to spy on a method that is directly imported by another
-module. GitLab has a custom `spyOnDependency` method which utilizes
-[babel-plugin-rewire](https://github.com/speedskater/babel-plugin-rewire) to
-achieve this. It can be used like so:
+#### `setTimeout()` / `setInterval()` in application
-```javascript
-// my_module.js
-import { visitUrl } from '~/lib/utils/url_utility';
+If the application itself is waiting for some time, mock await the waiting. In Jest this is already
+[done by default](https://gitlab.com/gitlab-org/gitlab/blob/a2128edfee799e49a8732bfa235e2c5e14949c68/jest.config.js#L47)
+(see also [Jest Timer Mocks](https://jestjs.io/docs/en/timer-mocks)). In Karma you can use the
+[Jasmine mock clock](https://jasmine.github.io/api/2.9/Clock.html).
-export default function doSomething() {
- visitUrl('/foo/bar');
-}
+```javascript
+const doSomethingLater = () => {
+ setTimeout(() => {
+ // do something
+ }, 4000);
+};
```
-```javascript
-// my_module_spec.js
-import doSomething from '~/my_module';
+**in Jest:**
-describe('my_module', () => {
- it('does something', () => {
- const visitUrl = spyOnDependency(doSomething, 'visitUrl');
+```javascript
+it('does something', () => {
+ doSomethingLater();
+ jest.runAllTimers();
- doSomething();
- expect(visitUrl).toHaveBeenCalledWith('/foo/bar');
- });
+ expect(something).toBe('done');
});
```
-Unlike `spyOn`, `spyOnDependency` expects its first parameter to be the default
-export of a module who's import you want to stub, rather than an object which
-contains a method you wish to stub (if the module does not have a default
-export, one is be generated by the babel plugin). The second parameter is the
-name of the import you wish to change. The result of the function is a Spy
-object which can be treated like any other Jasmine spy object.
+**in Karma:**
-Further documentation on the babel rewire plugin API can be found on
-[its repository Readme doc](https://github.com/speedskater/babel-plugin-rewire#babel-plugin-rewire).
+```javascript
+it('does something', () => {
+ jasmine.clock().install();
-#### Waiting in tests
+ doSomethingLater();
+ jasmine.clock().tick(4000);
+
+ expect(something).toBe('done');
+ jasmine.clock().uninstall();
+});
+```
+
+### Waiting in tests
Sometimes a test needs to wait for something to happen in the application before it continues.
Avoid using [`setTimeout`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout)
-because it makes the reason for waiting unclear and if passed a time larger than zero it will slow down our test suite.
+because it makes the reason for waiting unclear and if used within Karma with a time larger than zero it will slow down our test suite.
Instead use one of the following approaches.
-##### Promises and Ajax calls
+#### Promises and Ajax calls
Register handler functions to wait for the `Promise` to be resolved.
@@ -345,10 +383,9 @@ const askTheServer = () => {
**in Jest:**
```javascript
-it('waits for an Ajax call', () => {
- return askTheServer().then(() => {
- expect(something).toBe('done');
- });
+it('waits for an Ajax call', async () => {
+ await askTheServer()
+ expect(something).toBe('done');
});
```
@@ -378,25 +415,7 @@ it('waits for an Ajax call', () => {
});
```
-**in Karma:**
-
-You are out of luck. The following only works sometimes and may lead to flaky failures:
-
-```javascript
-it('waits for an Ajax call', done => {
- synchronousFunction();
-
- // create a new Promise and hope that it resolves after the rest
- Promise.resolve()
- .then(() => {
- expect(something).toBe('done');
- })
- .then(done)
- .catch(done.fail);
-});
-```
-
-##### Vue rendering
+#### Vue rendering
To wait until a Vue component is re-rendered, use either of the equivalent
[`Vue.nextTick()`](https://vuejs.org/v2/api/#Vue-nextTick) or `vm.$nextTick()`.
@@ -429,47 +448,7 @@ it('renders something', done => {
});
```
-##### `setTimeout()` / `setInterval()` in application
-
-If the application itself is waiting for some time, mock await the waiting. In Jest this is already
-[done by default](https://gitlab.com/gitlab-org/gitlab/blob/a2128edfee799e49a8732bfa235e2c5e14949c68/jest.config.js#L47)
-(see also [Jest Timer Mocks](https://jestjs.io/docs/en/timer-mocks)). In Karma you can use the
-[Jasmine mock clock](https://jasmine.github.io/api/2.9/Clock.html).
-
-```javascript
-const doSomethingLater = () => {
- setTimeout(() => {
- // do something
- }, 4000);
-};
-```
-
-**in Jest:**
-
-```javascript
-it('does something', () => {
- doSomethingLater();
- jest.runAllTimers();
-
- expect(something).toBe('done');
-});
-```
-
-**in Karma:**
-
-```javascript
-it('does something', () => {
- jasmine.clock().install();
-
- doSomethingLater();
- jasmine.clock().tick(4000);
-
- expect(something).toBe('done');
- jasmine.clock().uninstall();
-});
-```
-
-##### Events
+#### Events
If the application triggers an event that you need to wait for in your test, register an event handler which contains
the assertions:
@@ -501,7 +480,7 @@ it('waits for an event', () => {
});
```
-#### Ensuring that tests are isolated
+### Ensuring that tests are isolated
Tests are normally architected in a pattern which requires a recurring setup and breakdown of the component under test. This is done by making use of the `beforeEach` and `afterEach` hooks.
@@ -534,19 +513,51 @@ In order to ensure that a clean wrapper object and DOM are being used in each te
See also the [Vue Test Utils documentation on `destroy`](https://vue-test-utils.vuejs.org/api/wrapper/#destroy).
-#### Migrating flaky Karma tests to Jest
+## Factories
+
+TBU
+
+## Mocking Strategies with Jest
+
+### Stubbing and Mocking
+
+Jasmine provides stubbing and mocking capabilities. There are some subtle differences in how to use it within Karma and Jest.
+
+Stubs or spies are often used synonymously. In Jest it's quite easy thanks to the `.spyOn` method. [Official docs][jestspy]
+The more challenging part are mocks, which can be used for functions or even dependencies.
+
+### Manual module mocks
+
+Jest supports [manual module mocks](https://jestjs.io/docs/en/manual-mocks) by placing a mock in a `__mocks__/` directory next to the source module. **Don't do this.** We want to keep all of our test-related code in one place (the `spec/` folder), and the logic that Jest uses to apply mocks from `__mocks__/` is rather inconsistent.
-Some of our Karma tests are flaky because they access the properties of a shared scope.
-This also means that they are not easily parallelized.
+Instead, our test runner detects manual mocks from `spec/frontend/mocks/`. Any mock placed here is automatically picked up and injected whenever you import its source module.
+
+- Files in `spec/frontend/mocks/ce` will mock the corresponding CE module from `app/assets/javascripts`, mirroring the source module's path.
+ - Example: `spec/frontend/mocks/ce/lib/utils/axios_utils` will mock the module `~/lib/utils/axios_utils`.
+- Files in `spec/frontend/mocks/node` will mock NPM packages of the same name or path.
+- We don't support mocking EE modules yet.
-Migrating flaky Karma tests to Jest will help significantly as each test is executed
-in an isolated scope, improving performance and predictability.
+If a mock is found for which a source module doesn't exist, the test suite will fail. 'Virtual' mocks, or mocks that don't have a 1-to-1 association with a source module, are not supported yet.
-### Vue.js unit tests
+### Writing a mock
-See this [section][vue-test].
+Create a JS module in the appropriate place in `spec/frontend/mocks/`. That's it. It will automatically mock its source package in all tests.
-### Running frontend tests
+Make sure that your mock's export has the same format as the mocked module. So, if you're mocking a CommonJS module, you'll need to use `module.exports` instead of the ES6 `export`.
+
+It might be useful for a mock to expose a property that indicates if the mock was loaded. This way, tests can assert the presence of a mock without calling any logic and causing side-effects. The `~/lib/utils/axios_utils` module mock has such a property, `isMock`, that is `true` in the mock and undefined in the original class. Jest's mock functions also have a `mock` property that you can test.
+
+### Bypassing mocks
+
+If you ever need to import the original module in your tests, use [`jest.requireActual()`](https://jestjs.io/docs/en/jest-object#jestrequireactualmodulename) (or `jest.requireActual().default` for the default export). The `jest.mock()` and `jest.unmock()` won't have an effect on modules that have a manual mock, because mocks are imported and cached before any tests are run.
+
+### Keep mocks light
+
+Global mocks introduce magic and can affect how modules are imported in your tests. Try to keep them as light as possible and dependency-free. A global mock should be useful for any unit test. For example, the `axios_utils` and `jquery` module mocks throw an error when an HTTP request is attempted, since this is useful behaviour in &gt;99% of tests.
+
+When in doubt, construct mocks in your test file using [`jest.mock()`](https://jestjs.io/docs/en/jest-object#jestmockmodulename-factory-options), [`jest.spyOn()`](https://jestjs.io/docs/en/jest-object#jestspyonobject-methodname), etc.
+
+## Running Frontend Tests
For running the frontend tests, you need the following commands:
@@ -556,17 +567,40 @@ For running the frontend tests, you need the following commands:
As long as the fixtures don't change, `yarn test` is sufficient (and saves you some time).
-### Live testing and focused testing
+### Live testing and focused testing -- Jest
+
+While you work on a testsuite, you may want to run these specs in watch mode, so they rerun automatically on every save.
+
+```bash
+# Watch and rerun all specs matching the name icon
+yarn jest --watch icon
+
+# Watch and rerun one specifc file
+yarn jest --watch path/to/spec/file.spec.js
+```
+
+You can also run some focused tests without the `--watch` flag
+
+```bash
+# Run specific jest file
+yarn jest ./path/to/local_spec.js
+# Run specific jest folder
+yarn jest ./path/to/folder/
+# Run all jest files which path contain term
+yarn jest term
+```
-While developing locally, it may be helpful to keep Karma running so that you
-can get instant feedback on as you write tests and modify code. To do this
-you can start Karma with `yarn run karma-start`. It will compile the JavaScript
+### Live testing and focused testing -- Karma
+
+Karma allows something similar, but it's way more costly.
+
+Running Karma with `yarn run karma-start` will compile the JavaScript
assets and run a server at `http://localhost:9876/` where it will automatically
run the tests on any browser which connects to it. You can enter that url on
multiple browsers at once to have it run the tests on each in parallel.
While Karma is running, any changes you make will instantly trigger a recompile
-and retest of the entire test suite, so you can see instantly if you've broken
+and retest of the **entire test suite**, so you can see instantly if you've broken
a test with your changes. You can use [Jasmine focused][jasmine-focus] or
excluded tests (with `fdescribe` or `xdescribe`) to get Karma to run only the
tests you want while you're working on a specific feature, but make sure to
@@ -594,24 +628,6 @@ glob otherwise your shell may split it into multiple arguments:
yarn karma -f 'spec/javascripts/ide/**/file_spec.js'
```
-It is also possible to target individual Jest / RSpec tests:
-
-```bash
-# Run specific jest file
-yarn jest ./path/to/local_spec.js
-# Run specific jest folder
-yarn jest ./path/to/folder/
-# Run all jest files which path contain term
-yarn jest term
-```
-
-```bash
-# Run specific rspec file
-rspec ./path/to/local_spec.rb
-# Run specific block within rspec file
-rspec ./path/to/local_spec.rb:15
-```
-
## Frontend test fixtures
Code that is added to HAML templates (in `app/views/`) or makes Ajax requests to the backend has tests that require HTML or JSON from the backend.
@@ -654,6 +670,52 @@ Fixtures are regenerated using the `bin/rake frontend:fixtures` command but you
for example `bin/rspec spec/frontend/fixtures/merge_requests.rb`.
When creating a new fixture, it often makes sense to take a look at the corresponding tests for the endpoint in `(ee/)spec/controllers/` or `(ee/)spec/requests/`.
+## Data-driven tests
+
+Similar to [RSpec's parameterized tests](best_practices.md#table-based--parameterized-tests),
+Jest supports data-driven tests for:
+
+- Individual tests using [`test.each`](https://jestjs.io/docs/en/api#testeachtable-name-fn-timeout) (aliased to `it.each`).
+- Groups of tests using [`describe.each`](https://jestjs.io/docs/en/api#describeeachtable-name-fn-timeout).
+
+These can be useful for reducing repetition within tests. Each option can take an array of
+data values or a tagged template literal.
+
+For example:
+
+```javascript
+// function to test
+const icon = status => status ? 'pipeline-passed' : 'pipeline-failed'
+const message = status => status ? 'pipeline-passed' : 'pipeline-failed'
+
+// test with array block
+it.each([
+ [false, 'pipeline-failed'],
+ [true, 'pipeline-passed']
+])('icon with %s will return %s',
+ (status, icon) => {
+ expect(renderPipeline(status)).toEqual(icon)
+ }
+);
+```
+
+```javascript
+// test suite with tagged template literal block
+describe.each`
+ status | icon | message
+ ${false} | ${'pipeline-failed'} | ${'Pipeline failed - boo-urns'}
+ ${true} | ${'pipeline-passed'} | ${'Pipeline succeeded - win!'}
+`('pipeline component', ({ status, icon, message }) => {
+ it(`returns icon ${icon} with status ${status}`, () => {
+ expect(icon(status)).toEqual(message)
+ })
+
+ it(`returns message ${message} with status ${status}`, () => {
+ expect(message(status)).toEqual(message)
+ })
+});
+```
+
## Gotchas
### RSpec errors due to JavaScript
@@ -685,12 +747,6 @@ describe "Admin::AbuseReports", :js do
end
```
-[jasmine-focus]: https://jasmine.github.io/2.5/focused_specs.html
-[karma]: http://karma-runner.github.io/
-[vue-test]: ../fe_guide/vue.md#testing-vue-components
-[rspec]: https://github.com/rspec/rspec-rails#feature-specs
-[jasmine]: https://jasmine.github.io/
-
## Overview of Frontend Testing Levels
Tests relevant for frontend development can be found at the following places:
@@ -753,6 +809,7 @@ graph RL
end
```
+<div id="unit-testing-guidelines"></div>
#### When to use unit tests
<details>
@@ -1219,3 +1276,13 @@ You can download any older version of Firefox from the releases FTP server, <htt
---
[Return to Testing documentation](index.md)
+
+<!-- URL References -->
+
+[jasmine-focus]: https://jasmine.github.io/2.5/focused_specs.html
+[karma]: http://karma-runner.github.io/
+[vue-test]: ../fe_guide/vue.md#testing-vue-components
+[rspec]: https://github.com/rspec/rspec-rails#feature-specs
+[jasmine]: https://jasmine.github.io/
+[jest]: https://jestjs.io
+[jestspy]: https://jestjs.io/docs/en/jest-object#jestspyonobject-methodname
diff --git a/doc/user/project/releases/img/releases_count_v12_8.png b/doc/user/project/releases/img/releases_count_v12_8.png
new file mode 100644
index 00000000000..fae3b58d8e3
--- /dev/null
+++ b/doc/user/project/releases/img/releases_count_v12_8.png
Binary files differ
diff --git a/doc/user/project/releases/index.md b/doc/user/project/releases/index.md
index c253210af46..d9eda5cf6a4 100644
--- a/doc/user/project/releases/index.md
+++ b/doc/user/project/releases/index.md
@@ -94,6 +94,19 @@ project.
![Releases list](img/releases.png)
+### Number of Releases
+
+> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/36667) in GitLab 12.8.
+
+The incremental number of Releases is displayed on the project's details page. When clicked,
+it takes you to the list of Releases.
+
+![Number of Releases](img/releases_count_v12_8.png "Incremental counter of Releases")
+
+For private projects, the number of Releases is displayed to users with Reporter
+[permissions](../../permissions.md#releases-permissions) or higher. For public projects,
+it is displayed to every user regardless of their permission level.
+
## Editing a release
> [Introduced](https://gitlab.com/gitlab-org/gitlab/issues/26016) in GitLab 12.6.
diff --git a/doc/user/project/repository/forking_workflow.md b/doc/user/project/repository/forking_workflow.md
index 8aa2e0dce37..cd23f0bd434 100644
--- a/doc/user/project/repository/forking_workflow.md
+++ b/doc/user/project/repository/forking_workflow.md
@@ -60,4 +60,8 @@ changes will be added to the repository and branch you're merging into.
![New merge request](img/forking_workflow_merge_request.png)
+## Removing a fork relationship
+
+You can unlink your fork from its upstream project in the [advanced settings](../settings/index.md#removing-a-fork-relationship).
+
[gitlab flow]: https://about.gitlab.com/blog/2014/09/29/gitlab-flow/ "GitLab Flow blog post"
diff --git a/doc/user/project/repository/web_editor.md b/doc/user/project/repository/web_editor.md
index f41ff12d0a4..d847f4ddaaf 100644
--- a/doc/user/project/repository/web_editor.md
+++ b/doc/user/project/repository/web_editor.md
@@ -97,7 +97,8 @@ In case your development workflow dictates to have an issue for every merge
request, you can quickly create a branch right on the issue page which will be
tied with the issue itself. You can see a **Create merge request** dropdown
below the issue description unless there is already a branch with the same
-name or a referenced merge request.
+name or a referenced merge request or your project (still) has an active
+[fork relationship](../settings/index.md#advanced-settings).
![Create Button](img/web_editor_new_branch_from_issue_create_button_v12_6.png)
diff --git a/doc/user/project/settings/index.md b/doc/user/project/settings/index.md
index b4d4ec7a922..248c0e67520 100644
--- a/doc/user/project/settings/index.md
+++ b/doc/user/project/settings/index.md
@@ -1,8 +1,8 @@
# Project settings
NOTE: **Note:**
-Only project Maintainers and Admin users have the [permissions] to access a project
-settings.
+Only project Maintainers and Admin users have the [permissions](../../permissions.md#project-members-permissions)
+to access a project settings.
You can adjust your [project](../index.md) settings by navigating
to your project's homepage and clicking **Settings**.
@@ -106,12 +106,13 @@ Learn how to [export a project](import_export.md#importing-the-project) in GitLa
### Advanced settings
-Here you can run housekeeping, archive, rename, transfer, or remove a project.
+Here you can run housekeeping, archive, rename, transfer, [remove a fork relationship](#removing-a-fork-relationship), or remove a project.
#### Archiving a project
NOTE: **Note:**
-Only project Owners and Admin users have the [permissions] to archive a project.
+Only project Owners and Admin users have the [permissions](../../permissions.md#project-members-permissions)
+to archive a project.
Archiving a project makes it read-only for all users and indicates that it is
no longer actively maintained. Projects that have been archived can also be
@@ -130,7 +131,7 @@ To archive a project:
#### Renaming a repository
NOTE: **Note:**
-Only project Maintainers and Admin users have the [permissions] to rename a
+Only project Maintainers and Admin users have the [permissions](../../permissions.md#project-members-permissions) to rename a
repository. Not to be confused with a project's name where it can also be
changed from the [general project settings](#general-project-settings).
@@ -150,11 +151,12 @@ old URL will not be able to push or pull. Read more about what happens with the
#### Transferring an existing project into another namespace
NOTE: **Note:**
-Only project Owners and Admin users have the [permissions] to transfer a project.
+Only project Owners and Admin users have the [permissions](../../permissions.md#project-members-permissions)
+to transfer a project.
You can transfer an existing project into a [group](../../group/index.md) if:
-1. You have at least **Maintainer** [permissions] to that group.
+1. You have at least **Maintainer** [permissions](../../permissions.md#project-members-permissions) to that group.
1. The project is in a subgroup you own.
1. You are at least a **Maintainer** of the project under your personal namespace.
Similarly, if you are an owner of a group, you can transfer any of its projects
@@ -175,8 +177,6 @@ NOTE: **Note:**
GitLab administrators can use the admin interface to move any project to any
namespace if needed.
-[permissions]: ../../permissions.md#project-members-permissions
-
#### Remove a project
NOTE: **Note:**
@@ -202,6 +202,24 @@ To restore a project that is marked for deletion:
1. Navigate to your project, and select **{settings}** **Settings > General > Advanced**.
1. In the Restore project section, click the **Restore project** button.
+#### Removing a fork relationship
+
+Forking is a great way to [contribute to a project](../repository/forking_workflow.md)
+of which you are not a member.
+If you want to use the fork for yourself and do not need to send
+[merge requests](../merge_requests.md) to the upstream project,
+you can safely remove the fork relationship.
+
+To do so:
+
+1. Navigate to your project's **Settings > General > Advanced**.
+1. Under **Remove fork relationship**, click the likewise-labeled button.
+1. Confirm the action by typing the project's path as instructed.
+
+NOTE: **Note:**
+Only project maintainers have the [permissions](../../permissions.md#project-members-permissions)
+to remove a fork relationship.
+
## Operations settings
### Error Tracking
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 62eb30f2edf..f68365e6325 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -2,31 +2,6 @@
module API
module Entities
- class Membership < Grape::Entity
- expose :source_id
- expose :source_name do |member|
- member.source.name
- end
- expose :source_type
- expose :access_level
- end
-
- class Identity < Grape::Entity
- expose :provider, :extern_uid
- end
-
- class UserStatus < Grape::Entity
- expose :emoji
- expose :message
- expose :message_html do |entity|
- MarkupHelper.markdown_field(entity, :message)
- end
- end
-
- class Email < Grape::Entity
- expose :id, :email
- end
-
class Hook < Grape::Entity
expose :id, :url, :created_at, :push_events, :tag_push_events, :merge_requests_events, :repository_update_events
expose :enable_ssl_verification
diff --git a/lib/api/entities/email.rb b/lib/api/entities/email.rb
new file mode 100644
index 00000000000..5ba425def3d
--- /dev/null
+++ b/lib/api/entities/email.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class Email < Grape::Entity
+ expose :id, :email
+ end
+ end
+end
diff --git a/lib/api/entities/identity.rb b/lib/api/entities/identity.rb
new file mode 100644
index 00000000000..8969a0256c7
--- /dev/null
+++ b/lib/api/entities/identity.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class Identity < Grape::Entity
+ expose :provider, :extern_uid
+ end
+ end
+end
diff --git a/lib/api/entities/membership.rb b/lib/api/entities/membership.rb
new file mode 100644
index 00000000000..2e3e6a0d8ba
--- /dev/null
+++ b/lib/api/entities/membership.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class Membership < Grape::Entity
+ expose :source_id
+ expose :source_name do |member|
+ member.source.name
+ end
+ expose :source_type
+ expose :access_level
+ end
+ end
+end
diff --git a/lib/api/entities/user_status.rb b/lib/api/entities/user_status.rb
new file mode 100644
index 00000000000..9bc4cbf240f
--- /dev/null
+++ b/lib/api/entities/user_status.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+module API
+ module Entities
+ class UserStatus < Grape::Entity
+ expose :emoji
+ expose :message
+ expose :message_html do |entity|
+ MarkupHelper.markdown_field(entity, :message)
+ end
+ end
+ end
+end
diff --git a/lib/api/helpers/internal_helpers.rb b/lib/api/helpers/internal_helpers.rb
index cc9d45dcae4..b17cb2633d8 100644
--- a/lib/api/helpers/internal_helpers.rb
+++ b/lib/api/helpers/internal_helpers.rb
@@ -116,7 +116,7 @@ module API
# Project id to pass between components that don't share/don't have
# access to the same filesystem mounts
def gl_repository
- repo_type.identifier_for_repositorable(project)
+ repo_type.identifier_for_container(project)
end
def gl_project_path
diff --git a/lib/gitlab/gl_repository.rb b/lib/gitlab/gl_repository.rb
index 99bf4258c07..347084e779c 100644
--- a/lib/gitlab/gl_repository.rb
+++ b/lib/gitlab/gl_repository.rb
@@ -7,12 +7,13 @@ module Gitlab
PROJECT = RepoType.new(
name: :project,
access_checker_class: Gitlab::GitAccess,
- repository_accessor: -> (project) { project.repository }
+ repository_resolver: -> (project) { project.repository }
).freeze
WIKI = RepoType.new(
name: :wiki,
access_checker_class: Gitlab::GitAccessWiki,
- repository_accessor: -> (project) { project.wiki.repository }
+ repository_resolver: -> (project) { project.wiki.repository },
+ suffix: :wiki
).freeze
TYPES = {
@@ -27,15 +28,14 @@ module Gitlab
def self.parse(gl_repository)
type_name, _id = gl_repository.split('-').first
type = types[type_name]
- subject_id = type&.fetch_id(gl_repository)
- unless subject_id
+ unless type
raise ArgumentError, "Invalid GL Repository \"#{gl_repository}\""
end
- project = Project.find_by_id(subject_id)
+ container = type.fetch_container!(gl_repository)
- [project, type]
+ [container, type]
end
def self.default_type
diff --git a/lib/gitlab/gl_repository/repo_type.rb b/lib/gitlab/gl_repository/repo_type.rb
index 6918344aa40..20a0dd48468 100644
--- a/lib/gitlab/gl_repository/repo_type.rb
+++ b/lib/gitlab/gl_repository/repo_type.rb
@@ -5,16 +5,25 @@ module Gitlab
class RepoType
attr_reader :name,
:access_checker_class,
- :repository_accessor
+ :repository_resolver,
+ :container_resolver,
+ :suffix
- def initialize(name:, access_checker_class:, repository_accessor:)
+ def initialize(
+ name:,
+ access_checker_class:,
+ repository_resolver:,
+ container_resolver: default_container_resolver,
+ suffix: nil)
@name = name
@access_checker_class = access_checker_class
- @repository_accessor = repository_accessor
+ @repository_resolver = repository_resolver
+ @container_resolver = container_resolver
+ @suffix = suffix
end
- def identifier_for_repositorable(repositorable)
- "#{name}-#{repositorable.id}"
+ def identifier_for_container(container)
+ "#{name}-#{container.id}"
end
def fetch_id(identifier)
@@ -22,6 +31,14 @@ module Gitlab
match[:id] if match
end
+ def fetch_container!(identifier)
+ id = fetch_id(identifier)
+
+ raise ArgumentError, "Invalid GL Repository \"#{identifier}\"" unless id
+
+ container_resolver.call(id)
+ end
+
def wiki?
self == WIKI
end
@@ -31,11 +48,21 @@ module Gitlab
end
def path_suffix
- project? ? "" : ".#{name}"
+ suffix ? ".#{suffix}" : ''
end
- def repository_for(repositorable)
- repository_accessor.call(repositorable)
+ def repository_for(container)
+ repository_resolver.call(container)
+ end
+
+ def valid?(repository_path)
+ repository_path.end_with?(path_suffix)
+ end
+
+ private
+
+ def default_container_resolver
+ -> (id) { Project.find_by_id(id) }
end
end
end
diff --git a/lib/gitlab/repo_path.rb b/lib/gitlab/repo_path.rb
index 1baa2a9e461..e8c749cac14 100644
--- a/lib/gitlab/repo_path.rb
+++ b/lib/gitlab/repo_path.rb
@@ -4,8 +4,9 @@ module Gitlab
module RepoPath
NotFoundError = Class.new(StandardError)
- def self.parse(repo_path)
- project_path = repo_path.sub(/\.git\z/, '').sub(%r{\A/}, '')
+ def self.parse(path)
+ repo_path = path.sub(/\.git\z/, '').sub(%r{\A/}, '')
+ redirected_path = nil
# Detect the repo type based on the path, the first one tried is the project
# type, which does not have a suffix.
@@ -14,10 +15,13 @@ module Gitlab
# type.
# We'll always try to find a project with an empty suffix (for the
# `Gitlab::GlRepository::PROJECT` type.
- next unless project_path.end_with?(type.path_suffix)
+ next unless type.valid?(repo_path)
- project, was_redirected = find_project(project_path.chomp(type.path_suffix))
- redirected_path = project_path if was_redirected
+ # Removing the suffix (.wiki, .design, ...) from the project path
+ full_path = repo_path.chomp(type.path_suffix)
+
+ project, was_redirected = find_project(full_path)
+ redirected_path = repo_path if was_redirected
# If we found a matching project, then the type was matched, no need to
# continue looking.
diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb
index e377c690d51..8696e23cbc7 100644
--- a/lib/gitlab/workhorse.rb
+++ b/lib/gitlab/workhorse.rb
@@ -24,7 +24,7 @@ module Gitlab
attrs = {
GL_ID: Gitlab::GlId.gl_id(user),
- GL_REPOSITORY: repo_type.identifier_for_repositorable(repository.project),
+ GL_REPOSITORY: repo_type.identifier_for_container(repository.project),
GL_USERNAME: user&.username,
ShowAllRefs: show_all_refs,
Repository: repository.gitaly_repository.to_h,
diff --git a/spec/lib/gitlab/gl_repository/repo_type_spec.rb b/spec/lib/gitlab/gl_repository/repo_type_spec.rb
index 9e09e1411ab..8bbcc644f6d 100644
--- a/spec/lib/gitlab/gl_repository/repo_type_spec.rb
+++ b/spec/lib/gitlab/gl_repository/repo_type_spec.rb
@@ -2,33 +2,45 @@
require 'spec_helper'
describe Gitlab::GlRepository::RepoType do
- set(:project) { create(:project) }
+ let_it_be(:project) { create(:project) }
describe Gitlab::GlRepository::PROJECT do
it_behaves_like 'a repo type' do
let(:expected_identifier) { "project-#{project.id}" }
let(:expected_id) { project.id.to_s }
- let(:expected_suffix) { "" }
+ let(:expected_suffix) { '' }
let(:expected_repository) { project.repository }
+ let(:expected_container) { project }
end
- it "knows its type" do
+ it 'knows its type' do
expect(described_class).not_to be_wiki
expect(described_class).to be_project
end
+
+ it 'checks if repository path is valid' do
+ expect(described_class.valid?(project.repository.full_path)).to be_truthy
+ expect(described_class.valid?(project.wiki.repository.full_path)).to be_truthy
+ end
end
describe Gitlab::GlRepository::WIKI do
it_behaves_like 'a repo type' do
let(:expected_identifier) { "wiki-#{project.id}" }
let(:expected_id) { project.id.to_s }
- let(:expected_suffix) { ".wiki" }
+ let(:expected_suffix) { '.wiki' }
let(:expected_repository) { project.wiki.repository }
+ let(:expected_container) { project }
end
- it "knows its type" do
+ it 'knows its type' do
expect(described_class).to be_wiki
expect(described_class).not_to be_project
end
+
+ it 'checks if repository path is valid' do
+ expect(described_class.valid?(project.repository.full_path)).to be_falsey
+ expect(described_class.valid?(project.wiki.repository.full_path)).to be_truthy
+ end
end
end
diff --git a/spec/lib/gitlab/gl_repository_spec.rb b/spec/lib/gitlab/gl_repository_spec.rb
index 3290bef8aa5..3cfc4c2a132 100644
--- a/spec/lib/gitlab/gl_repository_spec.rb
+++ b/spec/lib/gitlab/gl_repository_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
describe ::Gitlab::GlRepository do
describe '.parse' do
- set(:project) { create(:project, :repository) }
+ let_it_be(:project) { create(:project, :repository) }
it 'parses a project gl_repository' do
expect(described_class.parse("project-#{project.id}")).to eq([project, Gitlab::GlRepository::PROJECT])
@@ -14,8 +14,12 @@ describe ::Gitlab::GlRepository do
expect(described_class.parse("wiki-#{project.id}")).to eq([project, Gitlab::GlRepository::WIKI])
end
- it 'throws an argument error on an invalid gl_repository' do
+ it 'throws an argument error on an invalid gl_repository type' do
expect { described_class.parse("badformat-#{project.id}") }.to raise_error(ArgumentError)
end
+
+ it 'throws an argument error on an invalid gl_repository id' do
+ expect { described_class.parse("project-foo") }.to raise_error(ArgumentError)
+ end
end
end
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index ee65561cc3e..51320b2c9f9 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -3992,7 +3992,7 @@ describe Project do
end
it 'schedules HashedStorage::ProjectMigrateWorker with delayed start when the project repo is in use' do
- Gitlab::ReferenceCounter.new(Gitlab::GlRepository::PROJECT.identifier_for_repositorable(project)).increase
+ Gitlab::ReferenceCounter.new(Gitlab::GlRepository::PROJECT.identifier_for_container(project)).increase
expect(HashedStorage::ProjectMigrateWorker).to receive(:perform_in)
@@ -4000,7 +4000,7 @@ describe Project do
end
it 'schedules HashedStorage::ProjectMigrateWorker with delayed start when the wiki repo is in use' do
- Gitlab::ReferenceCounter.new(Gitlab::GlRepository::WIKI.identifier_for_repositorable(project)).increase
+ Gitlab::ReferenceCounter.new(Gitlab::GlRepository::WIKI.identifier_for_container(project)).increase
expect(HashedStorage::ProjectMigrateWorker).to receive(:perform_in)
diff --git a/spec/requests/api/internal/base_spec.rb b/spec/requests/api/internal/base_spec.rb
index 6f784830f9d..29112fe5853 100644
--- a/spec/requests/api/internal/base_spec.rb
+++ b/spec/requests/api/internal/base_spec.rb
@@ -268,7 +268,7 @@ describe API::Internal::Base do
end
context 'with env passed as a JSON' do
- let(:gl_repository) { Gitlab::GlRepository::WIKI.identifier_for_repositorable(project) }
+ let(:gl_repository) { Gitlab::GlRepository::WIKI.identifier_for_container(project) }
it 'sets env in RequestStore' do
obj_dir_relative = './objects'
@@ -1054,9 +1054,9 @@ describe API::Internal::Base do
def gl_repository_for(project_or_wiki)
case project_or_wiki
when ProjectWiki
- Gitlab::GlRepository::WIKI.identifier_for_repositorable(project_or_wiki.project)
+ Gitlab::GlRepository::WIKI.identifier_for_container(project_or_wiki.project)
when Project
- Gitlab::GlRepository::PROJECT.identifier_for_repositorable(project_or_wiki)
+ Gitlab::GlRepository::PROJECT.identifier_for_container(project_or_wiki)
else
nil
end
diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb
index d9c398923c5..9f493fdffea 100644
--- a/spec/requests/git_http_spec.rb
+++ b/spec/requests/git_http_spec.rb
@@ -848,7 +848,7 @@ describe 'Git HTTP requests' do
end
it "redirects" do
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
end
end
@@ -890,7 +890,7 @@ describe 'Git HTTP requests' do
it "responds with status 200" do
clone_get(path, env) do |response|
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
diff --git a/spec/requests/jwt_controller_spec.rb b/spec/requests/jwt_controller_spec.rb
index 199c2dbe9ca..754ab3e6a45 100644
--- a/spec/requests/jwt_controller_spec.rb
+++ b/spec/requests/jwt_controller_spec.rb
@@ -15,12 +15,12 @@ describe JwtController do
context 'existing service' do
subject! { get '/jwt/auth', params: parameters }
- it { expect(response).to have_gitlab_http_status(200) }
+ it { expect(response).to have_gitlab_http_status(:ok) }
context 'returning custom http code' do
let(:service) { double(execute: { http_status: 505 }) }
- it { expect(response).to have_gitlab_http_status(505) }
+ it { expect(response).to have_gitlab_http_status(:http_version_not_supported) }
end
end
@@ -43,7 +43,7 @@ describe JwtController do
subject! { get '/jwt/auth', params: parameters, headers: headers }
- it { expect(response).to have_gitlab_http_status(401) }
+ it { expect(response).to have_gitlab_http_status(:unauthorized) }
end
context 'using personal access tokens' do
@@ -58,7 +58,7 @@ describe JwtController do
subject! { get '/jwt/auth', params: parameters, headers: headers }
it 'authenticates correctly' do
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(service_class).to have_received(:new).with(nil, user, ActionController::Parameters.new(parameters).permit!)
end
end
@@ -96,7 +96,7 @@ describe JwtController do
context 'without personal token' do
it 'rejects the authorization attempt' do
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP')
end
end
@@ -106,7 +106,7 @@ describe JwtController do
let(:headers) { { authorization: credentials(user.username, access_token.token) } }
it 'accepts the authorization attempt' do
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
@@ -116,7 +116,7 @@ describe JwtController do
get '/jwt/auth', params: parameters, headers: headers
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -127,7 +127,7 @@ describe JwtController do
it 'rejects the authorization attempt' do
get '/jwt/auth', params: parameters, headers: headers
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
expect(response.body).not_to include('You must use a personal access token with \'api\' scope for Git over HTTP')
end
end
@@ -139,7 +139,7 @@ describe JwtController do
end
get '/jwt/auth', params: parameters, headers: headers
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP')
end
end
@@ -150,7 +150,7 @@ describe JwtController do
it 'accepts the authorization attempt' do
get '/jwt/auth', params: parameters
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'allows read access' do
@@ -163,7 +163,7 @@ describe JwtController do
context 'unknown service' do
subject! { get '/jwt/auth', params: { service: 'unknown' } }
- it { expect(response).to have_gitlab_http_status(404) }
+ it { expect(response).to have_gitlab_http_status(:not_found) }
end
def credentials(login, password)
diff --git a/spec/requests/lfs_http_spec.rb b/spec/requests/lfs_http_spec.rb
index 62b9ee1d361..0e02c0f001b 100644
--- a/spec/requests/lfs_http_spec.rb
+++ b/spec/requests/lfs_http_spec.rb
@@ -227,7 +227,7 @@ describe 'Git LFS API and storage' do
end
it 'responds with redirect' do
- expect(response).to have_gitlab_http_status(302)
+ expect(response).to have_gitlab_http_status(:found)
end
it 'responds with the file location' do
@@ -1011,7 +1011,7 @@ describe 'Git LFS API and storage' do
it 'responds with status 403' do
subject
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
@@ -1027,7 +1027,7 @@ describe 'Git LFS API and storage' do
it 'responds with status 200' do
subject
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
object = LfsObject.find_by_oid(sample_oid)
expect(object).to be_present
@@ -1070,7 +1070,7 @@ describe 'Git LFS API and storage' do
it 'rejects slashes in the tempfile name (path traversal)' do
put_finalize('../bar', with_tempfile: true)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
diff --git a/spec/requests/lfs_locks_api_spec.rb b/spec/requests/lfs_locks_api_spec.rb
index 41f54162266..41cf1a80205 100644
--- a/spec/requests/lfs_locks_api_spec.rb
+++ b/spec/requests/lfs_locks_api_spec.rb
@@ -23,7 +23,7 @@ describe 'Git LFS File Locking API' do
it 'returns a forbidden 403 response' do
post_lfs_json url, body, headers
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
@@ -51,7 +51,7 @@ describe 'Git LFS File Locking API' do
it 'return an error message' do
post_lfs_json url, body, headers
- expect(response).to have_gitlab_http_status(409)
+ expect(response).to have_gitlab_http_status(:conflict)
expect(json_response.keys).to match_array(%w(lock message documentation_url))
expect(json_response['message']).to match(/already locked/)
@@ -68,7 +68,7 @@ describe 'Git LFS File Locking API' do
it 'creates the lock' do
post_lfs_json url, body, headers
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['lock'].keys).to match_array(%w(id path locked_at owner))
end
@@ -87,7 +87,7 @@ describe 'Git LFS File Locking API' do
do_get url, nil, headers
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['locks'].size).to eq(2)
expect(json_response['locks'].first.keys).to match_array(%w(id path locked_at owner))
@@ -106,7 +106,7 @@ describe 'Git LFS File Locking API' do
post_lfs_json url, nil, headers
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['ours'].size).to eq(1)
expect(json_response['ours'].first['path']).to eq('README')
@@ -126,7 +126,7 @@ describe 'Git LFS File Locking API' do
it 'deletes the lock' do
post_lfs_json url, nil, headers
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it 'returns the deleted lock' do
@@ -142,7 +142,7 @@ describe 'Git LFS File Locking API' do
project.add_maintainer(maintainer)
post_lfs_json url, { force: true }, headers
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
diff --git a/spec/requests/openid_connect_spec.rb b/spec/requests/openid_connect_spec.rb
index bac1a4e18c8..d7c08484dc4 100644
--- a/spec/requests/openid_connect_spec.rb
+++ b/spec/requests/openid_connect_spec.rb
@@ -75,7 +75,7 @@ describe 'OpenID Connect requests' do
it 'userinfo response is unauthorized' do
request_user_info!
- expect(response).to have_gitlab_http_status 403
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to be_blank
end
end
@@ -177,7 +177,7 @@ describe 'OpenID Connect requests' do
it 'correctly returns the configuration' do
get '/.well-known/openid-configuration'
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['issuer']).to eq('http://localhost')
expect(json_response['jwks_uri']).to eq('http://www.example.com/oauth/discovery/keys')
expect(json_response['scopes_supported']).to eq(%w[api read_user read_repository write_repository sudo openid profile email])
diff --git a/spec/requests/rack_attack_global_spec.rb b/spec/requests/rack_attack_global_spec.rb
index 9968b2e4aba..da0ca4c197a 100644
--- a/spec/requests/rack_attack_global_spec.rb
+++ b/spec/requests/rack_attack_global_spec.rb
@@ -53,7 +53,7 @@ describe 'Rack Attack global throttles' do
# At first, allow requests under the rate limit.
requests_per_period.times do
get url_that_does_not_require_authentication
- expect(response).to have_http_status 200
+ expect(response).to have_gitlab_http_status(:ok)
end
# the last straw
@@ -63,7 +63,7 @@ describe 'Rack Attack global throttles' do
it 'allows requests after throttling and then waiting for the next period' do
requests_per_period.times do
get url_that_does_not_require_authentication
- expect(response).to have_http_status 200
+ expect(response).to have_gitlab_http_status(:ok)
end
expect_rejection { get url_that_does_not_require_authentication }
@@ -71,7 +71,7 @@ describe 'Rack Attack global throttles' do
Timecop.travel(period.from_now) do
requests_per_period.times do
get url_that_does_not_require_authentication
- expect(response).to have_http_status 200
+ expect(response).to have_gitlab_http_status(:ok)
end
expect_rejection { get url_that_does_not_require_authentication }
@@ -81,7 +81,7 @@ describe 'Rack Attack global throttles' do
it 'counts requests from different IPs separately' do
requests_per_period.times do
get url_that_does_not_require_authentication
- expect(response).to have_http_status 200
+ expect(response).to have_gitlab_http_status(:ok)
end
expect_next_instance_of(Rack::Attack::Request) do |instance|
@@ -90,14 +90,14 @@ describe 'Rack Attack global throttles' do
# would be over limit for the same IP
get url_that_does_not_require_authentication
- expect(response).to have_http_status 200
+ expect(response).to have_gitlab_http_status(:ok)
end
context 'when the request is to the api internal endpoints' do
it 'allows requests over the rate limit' do
(1 + requests_per_period).times do
get url_api_internal, params: { secret_token: Gitlab::Shell.secret_token }
- expect(response).to have_http_status 200
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
@@ -109,7 +109,7 @@ describe 'Rack Attack global throttles' do
it 'does not cont as unauthenticated' do
(1 + requests_per_period).times do
post request_jobs_url, params: { token: runner.token }
- expect(response).to have_http_status 204
+ expect(response).to have_gitlab_http_status(:no_content)
end
end
end
@@ -117,7 +117,7 @@ describe 'Rack Attack global throttles' do
it 'logs RackAttack info into structured logs' do
requests_per_period.times do
get url_that_does_not_require_authentication
- expect(response).to have_http_status 200
+ expect(response).to have_gitlab_http_status(:ok)
end
arguments = {
@@ -143,7 +143,7 @@ describe 'Rack Attack global throttles' do
it 'allows requests over the rate limit' do
(1 + requests_per_period).times do
get url_that_does_not_require_authentication
- expect(response).to have_http_status 200
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
@@ -243,7 +243,7 @@ describe 'Rack Attack global throttles' do
it 'allows requests over the rate limit' do
(1 + requests_per_period).times do
post protected_path_that_does_not_require_authentication, params: post_params
- expect(response).to have_http_status 200
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
@@ -257,7 +257,7 @@ describe 'Rack Attack global throttles' do
it 'rejects requests over the rate limit' do
requests_per_period.times do
post protected_path_that_does_not_require_authentication, params: post_params
- expect(response).to have_http_status 200
+ expect(response).to have_gitlab_http_status(:ok)
end
expect_rejection { post protected_path_that_does_not_require_authentication, params: post_params }
@@ -272,7 +272,7 @@ describe 'Rack Attack global throttles' do
it 'allows requests over the rate limit' do
(1 + requests_per_period).times do
post protected_path_that_does_not_require_authentication, params: post_params
- expect(response).to have_http_status 200
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
@@ -329,7 +329,7 @@ describe 'Rack Attack global throttles' do
it 'allows requests over the rate limit' do
(1 + requests_per_period).times do
post(*request_args)
- expect(response).not_to have_http_status 429
+ expect(response).not_to have_gitlab_http_status(:too_many_requests)
end
end
end
@@ -369,7 +369,7 @@ describe 'Rack Attack global throttles' do
it 'allows requests over the rate limit' do
(1 + requests_per_period).times do
post url_that_requires_authentication
- expect(response).not_to have_http_status 429
+ expect(response).not_to have_gitlab_http_status(:too_many_requests)
end
end
end
diff --git a/spec/requests/user_avatar_spec.rb b/spec/requests/user_avatar_spec.rb
index 9451674161c..66c7ce4d533 100644
--- a/spec/requests/user_avatar_spec.rb
+++ b/spec/requests/user_avatar_spec.rb
@@ -19,7 +19,7 @@ describe 'Loading a user avatar' do
it 'only performs three SQL queries' do
get user.avatar_url # Skip queries on first application load
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect { get user.avatar_url }.not_to exceed_query_limit(3)
end
end
@@ -29,7 +29,7 @@ describe 'Loading a user avatar' do
it 'only performs two SQL queries' do
get user.avatar_url # Skip queries on first application load
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect { get user.avatar_url }.not_to exceed_query_limit(2)
end
end
diff --git a/spec/services/akismet_service_spec.rb b/spec/services/akismet_service_spec.rb
new file mode 100644
index 00000000000..4f1c23b701b
--- /dev/null
+++ b/spec/services/akismet_service_spec.rb
@@ -0,0 +1,137 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe AkismetService do
+ let(:fake_akismet_client) { double(:akismet_client) }
+
+ let_it_be(:text) { "Would you like to buy some tinned meat product?" }
+ let_it_be(:spam_owner) { create(:user) }
+
+ subject do
+ options = { ip_address: '1.2.3.4', user_agent: 'some user_agent', referrer: 'some referrer' }
+ described_class.new(spam_owner.name, spam_owner.email, text, options)
+ end
+
+ before do
+ stub_application_setting(akismet_enabled: true)
+ allow(subject).to receive(:akismet_client).and_return(fake_akismet_client)
+ end
+
+ shared_examples 'no activity if Akismet is not enabled' do |method_call|
+ # if the method name is `submit`, it requires an argument, so add it
+ before do
+ stub_application_setting(akismet_enabled: false)
+ end
+
+ it 'is automatically false' do
+ expect(subject.send(method_call)).to be_falsey
+ end
+
+ it 'performs no check' do
+ expect(fake_akismet_client).not_to receive(:public_send)
+
+ subject.send(method_call)
+ end
+ end
+
+ shared_examples 'false if Akismet is not available' do |method_call|
+ context 'if Akismet is not available' do
+ before do
+ allow(fake_akismet_client).to receive(:public_send).and_raise(StandardError.new("oh noes!"))
+ end
+
+ specify do
+ expect(subject.send(method_call)).to be_falsey
+ end
+
+ it 'logs an error' do
+ logger_spy = double(:logger)
+ expect(Rails).to receive(:logger).and_return(logger_spy)
+ expect(logger_spy).to receive(:error).with(/skipping/)
+
+ subject.send(method_call)
+ end
+ end
+ end
+
+ describe '#spam?' do
+ it_behaves_like 'no activity if Akismet is not enabled', :spam?, :check
+
+ context 'if Akismet is enabled' do
+ context 'the text is spam' do
+ before do
+ allow(fake_akismet_client).to receive(:check).and_return([true, false])
+ end
+
+ specify do
+ expect(subject.spam?).to be_truthy
+ end
+ end
+
+ context 'the text is blatant spam' do
+ before do
+ allow(fake_akismet_client).to receive(:check).and_return([false, true])
+ end
+
+ specify do
+ expect(subject.spam?).to be_truthy
+ end
+ end
+
+ context 'the text is not spam' do
+ before do
+ allow(fake_akismet_client).to receive(:check).and_return([false, false])
+ end
+
+ specify do
+ expect(subject.spam?).to be_falsey
+ end
+ end
+
+ context 'if Akismet is not available' do
+ before do
+ allow(fake_akismet_client).to receive(:check).and_raise(StandardError.new("oh noes!"))
+ end
+
+ specify do
+ expect(subject.spam?).to be_falsey
+ end
+
+ it 'logs an error' do
+ logger_spy = double(:logger)
+ expect(Rails).to receive(:logger).and_return(logger_spy)
+ expect(logger_spy).to receive(:error).with(/skipping check/)
+
+ subject.spam?
+ end
+ end
+ end
+ end
+
+ describe '#submit_ham' do
+ it_behaves_like 'no activity if Akismet is not enabled', :submit_ham
+ it_behaves_like 'false if Akismet is not available', :submit_ham
+
+ context 'if Akismet is available' do
+ specify do
+ expect(fake_akismet_client).to receive(:public_send).with(:ham, any_args)
+
+ expect(subject.submit_ham).to be_truthy
+ end
+ end
+ end
+
+ describe '#submit_spam' do
+ it_behaves_like 'no activity if Akismet is not enabled', :submit_spam
+ it_behaves_like 'false if Akismet is not available', :submit_spam
+
+ context 'if Akismet is available' do
+ specify do
+ expect(fake_akismet_client).to receive(:public_send).with(:spam, any_args)
+
+ expect(subject.submit_spam).to be_truthy
+ end
+ end
+ end
+end
diff --git a/spec/services/ci/create_pipeline_service/pre_post_stages_spec.rb b/spec/services/ci/create_pipeline_service/pre_post_stages_spec.rb
index db9b89f090f..2b11b98f58c 100644
--- a/spec/services/ci/create_pipeline_service/pre_post_stages_spec.rb
+++ b/spec/services/ci/create_pipeline_service/pre_post_stages_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
describe Ci::CreatePipelineService do
- context '.pre/.post stages' do
+ describe '.pre/.post stages' do
let_it_be(:user) { create(:admin) }
let_it_be(:project) { create(:project, :repository, creator: user) }
diff --git a/spec/support/shared_examples/lib/gitlab/repo_type_shared_examples.rb b/spec/support/shared_examples/lib/gitlab/repo_type_shared_examples.rb
index f4960b9f134..3d88b317417 100644
--- a/spec/support/shared_examples/lib/gitlab/repo_type_shared_examples.rb
+++ b/spec/support/shared_examples/lib/gitlab/repo_type_shared_examples.rb
@@ -1,30 +1,40 @@
# frozen_string_literal: true
RSpec.shared_examples 'a repo type' do
- describe "#identifier_for_repositorable" do
- subject { described_class.identifier_for_repositorable(project) }
+ describe '#identifier_for_container' do
+ subject { described_class.identifier_for_container(project) }
it { is_expected.to eq(expected_identifier) }
end
- describe "#fetch_id" do
- it "finds an id match in the identifier" do
+ describe '#fetch_id' do
+ it 'finds an id match in the identifier' do
expect(described_class.fetch_id(expected_identifier)).to eq(expected_id)
end
it 'does not break on other identifiers' do
- expect(described_class.fetch_id("wiki-noid")).to eq(nil)
+ expect(described_class.fetch_id('wiki-noid')).to eq(nil)
end
end
- describe "#path_suffix" do
+ describe '#fetch_container!' do
+ it 'returns the container' do
+ expect(described_class.fetch_container!(expected_identifier)).to eq expected_container
+ end
+
+ it 'raises an exception if the identifier is invalid' do
+ expect { described_class.fetch_container!('project-noid') }.to raise_error ArgumentError
+ end
+ end
+
+ describe '#path_suffix' do
subject { described_class.path_suffix }
it { is_expected.to eq(expected_suffix) }
end
- describe "#repository_for" do
- it "finds the repository for the repo type" do
+ describe '#repository_for' do
+ it 'finds the repository for the repo type' do
expect(described_class.repository_for(project)).to eq(expected_repository)
end
end
diff --git a/tooling/overcommit/Makefile b/tooling/overcommit/Makefile
new file mode 100644
index 00000000000..7da3c7c0569
--- /dev/null
+++ b/tooling/overcommit/Makefile
@@ -0,0 +1,7 @@
+.PHONY: install
+
+install:
+ if [ -e ../../.overcommit.yml ]; then cp -f ../../.overcommit.yml ../../.overcommit.yml.backup; fi
+ cp ../../.overcommit.yml.example ../../.overcommit.yml
+ bundle install
+ cd ../../ && overcommit -i
diff --git a/tooling/overcommit/gems.locked b/tooling/overcommit/gems.locked
new file mode 100644
index 00000000000..36e03551815
--- /dev/null
+++ b/tooling/overcommit/gems.locked
@@ -0,0 +1,75 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ ast (2.4.0)
+ childprocess (3.0.0)
+ ffi (1.12.1)
+ gitlab-styles (3.1.0)
+ rubocop (~> 0.74.0)
+ rubocop-gitlab-security (~> 0.1.0)
+ rubocop-performance (~> 1.4.1)
+ rubocop-rails (~> 2.0)
+ rubocop-rspec (~> 1.36)
+ haml (5.1.2)
+ temple (>= 0.8.0)
+ tilt
+ haml_lint (0.34.1)
+ haml (>= 4.0, < 5.2)
+ rainbow
+ rubocop (>= 0.50.0)
+ sysexits (~> 1.1)
+ iniparse (1.4.4)
+ jaro_winkler (1.5.4)
+ overcommit (0.52.1)
+ childprocess (>= 0.6.3, < 4)
+ iniparse (~> 1.4)
+ parallel (1.19.1)
+ parser (2.7.0.2)
+ ast (~> 2.4.0)
+ rack (2.1.1)
+ rainbow (3.0.0)
+ rake (12.3.3)
+ rb-fsevent (0.10.3)
+ rb-inotify (0.10.1)
+ ffi (~> 1.0)
+ rubocop (0.74.0)
+ jaro_winkler (~> 1.5.1)
+ parallel (~> 1.10)
+ parser (>= 2.6)
+ rainbow (>= 2.2.2, < 4.0)
+ ruby-progressbar (~> 1.7)
+ unicode-display_width (>= 1.4.0, < 1.7)
+ rubocop-gitlab-security (0.1.1)
+ rubocop (>= 0.51)
+ rubocop-performance (1.4.1)
+ rubocop (>= 0.71.0)
+ rubocop-rails (2.4.1)
+ rack (>= 1.1)
+ rubocop (>= 0.72.0)
+ rubocop-rspec (1.37.1)
+ rubocop (>= 0.68.1)
+ ruby-progressbar (1.10.1)
+ sass (3.5.7)
+ sass-listen (~> 4.0.0)
+ sass-listen (4.0.0)
+ rb-fsevent (~> 0.9, >= 0.9.4)
+ rb-inotify (~> 0.9, >= 0.9.7)
+ scss_lint (0.56.0)
+ rake (>= 0.9, < 13)
+ sass (~> 3.5.3)
+ sysexits (1.2.0)
+ temple (0.8.2)
+ tilt (2.0.10)
+ unicode-display_width (1.6.1)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ gitlab-styles (~> 3.1.0)
+ haml_lint (~> 0.34.0)
+ overcommit
+ scss_lint (~> 0.56.0)
+
+BUNDLED WITH
+ 2.1.2
diff --git a/tooling/overcommit/gems.rb b/tooling/overcommit/gems.rb
new file mode 100644
index 00000000000..c563a23275a
--- /dev/null
+++ b/tooling/overcommit/gems.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+# Make sure to run `bundle install --gemfile=tooling/overcommit/gems.rb` when you update this file.
+source 'https://rubygems.org'
+
+gem 'overcommit'
+gem 'gitlab-styles', '~> 3.1.0', require: false
+gem 'scss_lint', '~> 0.56.0', require: false
+gem 'haml_lint', '~> 0.34.0', require: false