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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-10 15:09:36 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-10 15:09:36 +0300
commitc6a33b298229f9e04933be43d6176c476ef03012 (patch)
tree66b336ef374b813d6e9c7f6a19264060a1f23f91
parentc52b81f45762cb7f05a950689dfc6d51b197ea73 (diff)
Add latest changes from gitlab-org/gitlab@master
-rw-r--r--app/assets/javascripts/ide/services/index.js2
-rw-r--r--app/finders/license_template_finder.rb4
-rw-r--r--app/finders/projects_finder.rb4
-rw-r--r--app/finders/template_finder.rb4
-rw-r--r--app/models/container_expiration_policy.rb1
-rw-r--r--app/models/project.rb2
-rw-r--r--app/presenters/clusters/cluster_presenter.rb2
-rw-r--r--changelogs/unreleased/210316-rearrange-project-level-analytics-sidebar-menu.yml5
-rw-r--r--changelogs/unreleased/211602-add-and-commit-empty-file-started-with-dot-in-web-ide-opens-gitlab.yml5
-rw-r--r--changelogs/unreleased/213554-default-jira-issues-import-to-enabled.yml5
-rw-r--r--changelogs/unreleased/app-finders-prepend.yml5
-rw-r--r--db/migrate/20200401095430_add_jsonb_to_geo_node_status_table.rb14
-rw-r--r--db/structure.sql4
-rw-r--r--doc/api/graphql/reference/gitlab_schema.graphql9
-rw-r--r--doc/api/graphql/reference/gitlab_schema.json20
-rw-r--r--doc/api/graphql/reference/index.md3
-rw-r--r--doc/user/project/img/status_page_detail_v12_10.pngbin0 -> 37911 bytes
-rw-r--r--doc/user/project/img/status_page_incidents_v12_10.pngbin0 -> 27792 bytes
-rw-r--r--doc/user/project/status_page/index.md96
-rw-r--r--lib/gitlab/usage_data.rb25
-rw-r--r--spec/features/projects/navbar_spec.rb17
-rw-r--r--spec/frontend/ide/services/index_spec.js81
-rw-r--r--spec/frontend/ide/stores/actions/file_spec.js2
-rw-r--r--spec/lib/gitlab/usage_data_spec.rb37
-rw-r--r--spec/support/helpers/usage_data_helpers.rb19
25 files changed, 349 insertions, 17 deletions
diff --git a/app/assets/javascripts/ide/services/index.js b/app/assets/javascripts/ide/services/index.js
index 84a2b2bd58e..3adf0cf073f 100644
--- a/app/assets/javascripts/ide/services/index.js
+++ b/app/assets/javascripts/ide/services/index.js
@@ -25,7 +25,7 @@ export default {
return Promise.resolve(file.content);
}
- if (file.raw) {
+ if (file.raw || !file.rawPath) {
return Promise.resolve(file.raw);
}
diff --git a/app/finders/license_template_finder.rb b/app/finders/license_template_finder.rb
index 1db175e1308..4d68b963dc3 100644
--- a/app/finders/license_template_finder.rb
+++ b/app/finders/license_template_finder.rb
@@ -13,8 +13,6 @@
class LicenseTemplateFinder
include Gitlab::Utils::StrongMemoize
- prepend_if_ee('::EE::LicenseTemplateFinder') # rubocop: disable Cop/InjectEnterpriseEditionModule
-
attr_reader :project, :params
def initialize(project, params = {})
@@ -52,3 +50,5 @@ class LicenseTemplateFinder
params.fetch(:popular, nil)
end
end
+
+LicenseTemplateFinder.prepend_if_ee('::EE::LicenseTemplateFinder')
diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb
index 23648e0f494..3a84600b09f 100644
--- a/app/finders/projects_finder.rb
+++ b/app/finders/projects_finder.rb
@@ -27,8 +27,6 @@
class ProjectsFinder < UnionFinder
include CustomAttributesFilter
- prepend_if_ee('::EE::ProjectsFinder') # rubocop: disable Cop/InjectEnterpriseEditionModule
-
attr_accessor :params
attr_reader :current_user, :project_ids_relation
@@ -225,3 +223,5 @@ class ProjectsFinder < UnionFinder
{ min_access_level: params[:min_access_level] }
end
end
+
+ProjectsFinder.prepend_if_ee('::EE::ProjectsFinder')
diff --git a/app/finders/template_finder.rb b/app/finders/template_finder.rb
index dfea3d427c2..78c8392f1cd 100644
--- a/app/finders/template_finder.rb
+++ b/app/finders/template_finder.rb
@@ -3,8 +3,6 @@
class TemplateFinder
include Gitlab::Utils::StrongMemoize
- prepend_if_ee('::EE::TemplateFinder') # rubocop: disable Cop/InjectEnterpriseEditionModule
-
VENDORED_TEMPLATES = HashWithIndifferentAccess.new(
dockerfiles: ::Gitlab::Template::DockerfileTemplate,
gitignores: ::Gitlab::Template::GitignoreTemplate,
@@ -42,3 +40,5 @@ class TemplateFinder
end
end
end
+
+TemplateFinder.prepend_if_ee('::EE::TemplateFinder')
diff --git a/app/models/container_expiration_policy.rb b/app/models/container_expiration_policy.rb
index ccb0a0f8acd..76bfbabf3b3 100644
--- a/app/models/container_expiration_policy.rb
+++ b/app/models/container_expiration_policy.rb
@@ -2,6 +2,7 @@
class ContainerExpirationPolicy < ApplicationRecord
include Schedulable
+ include UsageStatistics
belongs_to :project, inverse_of: :container_expiration_policy
diff --git a/app/models/project.rb b/app/models/project.rb
index 4cd92b119b4..ee4cc6157eb 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -787,7 +787,7 @@ class Project < ApplicationRecord
end
def jira_issues_import_feature_flag_enabled?
- Feature.enabled?(:jira_issue_import, self)
+ Feature.enabled?(:jira_issue_import, self, default_enabled: true)
end
def team
diff --git a/app/presenters/clusters/cluster_presenter.rb b/app/presenters/clusters/cluster_presenter.rb
index 3ace27c72d5..c4e3393cac9 100644
--- a/app/presenters/clusters/cluster_presenter.rb
+++ b/app/presenters/clusters/cluster_presenter.rb
@@ -89,3 +89,5 @@ module Clusters
end
end
end
+
+Clusters::ClusterPresenter.prepend_if_ee('EE::Clusters::ClusterPresenter')
diff --git a/changelogs/unreleased/210316-rearrange-project-level-analytics-sidebar-menu.yml b/changelogs/unreleased/210316-rearrange-project-level-analytics-sidebar-menu.yml
new file mode 100644
index 00000000000..77068c643a9
--- /dev/null
+++ b/changelogs/unreleased/210316-rearrange-project-level-analytics-sidebar-menu.yml
@@ -0,0 +1,5 @@
+---
+title: Make "Value Stream" the default page that appears when clicking the project-level "Analytics" sidebar item.
+merge_request: 27279
+author: Gilang Gumilar
+type: added
diff --git a/changelogs/unreleased/211602-add-and-commit-empty-file-started-with-dot-in-web-ide-opens-gitlab.yml b/changelogs/unreleased/211602-add-and-commit-empty-file-started-with-dot-in-web-ide-opens-gitlab.yml
new file mode 100644
index 00000000000..c32bc4539e4
--- /dev/null
+++ b/changelogs/unreleased/211602-add-and-commit-empty-file-started-with-dot-in-web-ide-opens-gitlab.yml
@@ -0,0 +1,5 @@
+---
+title: Fix incorrect content returned on empty dotfile
+merge_request: 28144
+author:
+type: fixed
diff --git a/changelogs/unreleased/213554-default-jira-issues-import-to-enabled.yml b/changelogs/unreleased/213554-default-jira-issues-import-to-enabled.yml
new file mode 100644
index 00000000000..0b0ad2969d4
--- /dev/null
+++ b/changelogs/unreleased/213554-default-jira-issues-import-to-enabled.yml
@@ -0,0 +1,5 @@
+---
+title: Add jira issues import feature
+merge_request:
+author:
+type: added
diff --git a/changelogs/unreleased/app-finders-prepend.yml b/changelogs/unreleased/app-finders-prepend.yml
new file mode 100644
index 00000000000..49758849f90
--- /dev/null
+++ b/changelogs/unreleased/app-finders-prepend.yml
@@ -0,0 +1,5 @@
+---
+title: Move prepend to last line in finders files
+merge_request: 29274
+author: Rajendra Kadam
+type: fixed
diff --git a/db/migrate/20200401095430_add_jsonb_to_geo_node_status_table.rb b/db/migrate/20200401095430_add_jsonb_to_geo_node_status_table.rb
new file mode 100644
index 00000000000..46eb826341c
--- /dev/null
+++ b/db/migrate/20200401095430_add_jsonb_to_geo_node_status_table.rb
@@ -0,0 +1,14 @@
+# frozen_string_literal: true
+
+# See https://docs.gitlab.com/ee/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class AddJsonbToGeoNodeStatusTable < ActiveRecord::Migration[6.0]
+ DOWNTIME = false
+
+ def change
+ change_table :geo_node_statuses do |t|
+ t.jsonb :status, null: false, default: {}
+ end
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index d45ad4f739c..90585a157cf 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -2650,7 +2650,8 @@ CREATE TABLE public.geo_node_statuses (
design_repositories_count integer,
design_repositories_synced_count integer,
design_repositories_failed_count integer,
- design_repositories_registry_count integer
+ design_repositories_registry_count integer,
+ status jsonb DEFAULT '{}'::jsonb NOT NULL
);
CREATE SEQUENCE public.geo_node_statuses_id_seq
@@ -13076,6 +13077,7 @@ COPY "schema_migrations" (version) FROM STDIN;
20200331132103
20200331195952
20200331220930
+20200401095430
20200401211005
20200402123926
20200402124802
diff --git a/doc/api/graphql/reference/gitlab_schema.graphql b/doc/api/graphql/reference/gitlab_schema.graphql
index 402415b985c..e79d52d4d10 100644
--- a/doc/api/graphql/reference/gitlab_schema.graphql
+++ b/doc/api/graphql/reference/gitlab_schema.graphql
@@ -8353,9 +8353,9 @@ scalar Time
type Timelog {
"""
- The date when the time tracked was spent at
+ Timestamp of when the time tracked was spent at. Deprecated in 12.10: Use `spentAt`
"""
- date: Time!
+ date: Time! @deprecated(reason: "Use `spentAt`. Deprecated in 12.10")
"""
The issue that logged time was added to
@@ -8363,6 +8363,11 @@ type Timelog {
issue: Issue
"""
+ Timestamp of when the time tracked was spent at
+ """
+ spentAt: Time
+
+ """
The time spent displayed in seconds
"""
timeSpent: Int!
diff --git a/doc/api/graphql/reference/gitlab_schema.json b/doc/api/graphql/reference/gitlab_schema.json
index c214d7c3299..820f41755d0 100644
--- a/doc/api/graphql/reference/gitlab_schema.json
+++ b/doc/api/graphql/reference/gitlab_schema.json
@@ -25299,7 +25299,7 @@
"fields": [
{
"name": "date",
- "description": "The date when the time tracked was spent at",
+ "description": "Timestamp of when the time tracked was spent at. Deprecated in 12.10: Use `spentAt`",
"args": [
],
@@ -25312,8 +25312,8 @@
"ofType": null
}
},
- "isDeprecated": false,
- "deprecationReason": null
+ "isDeprecated": true,
+ "deprecationReason": "Use `spentAt`. Deprecated in 12.10"
},
{
"name": "issue",
@@ -25330,6 +25330,20 @@
"deprecationReason": null
},
{
+ "name": "spentAt",
+ "description": "Timestamp of when the time tracked was spent at",
+ "args": [
+
+ ],
+ "type": {
+ "kind": "SCALAR",
+ "name": "Time",
+ "ofType": null
+ },
+ "isDeprecated": false,
+ "deprecationReason": null
+ },
+ {
"name": "timeSpent",
"description": "The time spent displayed in seconds",
"args": [
diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md
index fe5925b95d9..6ed3c5a778e 100644
--- a/doc/api/graphql/reference/index.md
+++ b/doc/api/graphql/reference/index.md
@@ -1306,8 +1306,9 @@ Completion status of tasks
| Name | Type | Description |
| --- | ---- | ---------- |
-| `date` | Time! | The date when the time tracked was spent at |
+| `date` **{warning-solid}** | Time! | **Deprecated:** Use `spentAt`. Deprecated in 12.10 |
| `issue` | Issue | The issue that logged time was added to |
+| `spentAt` | Time | Timestamp of when the time tracked was spent at |
| `timeSpent` | Int! | The time spent displayed in seconds |
| `user` | User! | The user that logged the time |
diff --git a/doc/user/project/img/status_page_detail_v12_10.png b/doc/user/project/img/status_page_detail_v12_10.png
new file mode 100644
index 00000000000..d8dbbb539e6
--- /dev/null
+++ b/doc/user/project/img/status_page_detail_v12_10.png
Binary files differ
diff --git a/doc/user/project/img/status_page_incidents_v12_10.png b/doc/user/project/img/status_page_incidents_v12_10.png
new file mode 100644
index 00000000000..ccc1eef3ea3
--- /dev/null
+++ b/doc/user/project/img/status_page_incidents_v12_10.png
Binary files differ
diff --git a/doc/user/project/status_page/index.md b/doc/user/project/status_page/index.md
new file mode 100644
index 00000000000..2a022fe472d
--- /dev/null
+++ b/doc/user/project/status_page/index.md
@@ -0,0 +1,96 @@
+# GitLab Status Page
+
+> [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/2479) in GitLab 12.10.
+
+GitLab Status Page allows you to create and deploy a static website to communicate efficiently to users during an incident.
+
+## How to set up
+
+NOTE: **Note:**
+Only AWS S3 is supported as a deploy target.
+
+```mermaid
+graph TB
+ subgraph GitLab Instance
+ issues(issue updates) -- trigger --> middleware(Background job: JSON generation)
+ end
+ subgraph Cloud Provider
+ middleware --saves data --> c1(Cloud Bucket stores JSON file)
+ end
+ subgraph Status Page
+ d(Static Site on CDN) -- fetches data --> c1
+ end
+```
+
+Setting up a Status Page is pretty painless but there are a few things you need to do.
+
+### Cloud account set up
+
+To use GitLab Status Page you first need to set up your account details for your cloud provider in the operations settings page. Today, only AWS is supported.
+
+1. Within your AWS account, create an AWS access key.
+1. Add the following permissions policies:
+ - [Create bucket](https://gitlab.com/gitlab-org/status-page/-/blob/master/deploy/etc/s3_create_policy.json).
+ - [Update bucket contents](https://gitlab.com/gitlab-org/status-page/-/blob/master/deploy/etc/s3_update_bucket_policy.json) (Remember replace `S3_BUCKET_NAME` with your bucket name).
+
+### Status Page project
+
+To deploy the status page to AWS S3 you need to add the Status Page project & configure the necessary CI variables.
+
+1. Fork the [Status Page](https://gitlab.com/gitlab-org/status-page) project. This can also be done via [Repository Mirroring](https://gitlab.com/gitlab-org/status-page#repository-mirroring) which will ensure you get the up-to-date Status Page features.
+1. Add the following variables in **Settings > CI/CD > Variables**. (To get these variables from Amazon, use your Amazon Console):
+ - `S3_BUCKET_NAME` - name of the Amazon S3 bucket
+ - `AWS_DEFAULT_REGION` - the AWS region
+ - `AWS_ACCESS_KEY_ID` - the AWS access key ID
+ - `AWS_SECRET_ACCESS_KEY` - the AWS secret
+1. Run the pipeline to deploy the status page to S3.
+
+### Syncing incidents to the Status Page
+
+Once the CI/CD variables are set, you'll need to set up the Project you want to use for Incident issues:
+
+1. Navigate to **Settings > Operations > Status Page**.
+1. Fill in your cloud provider's credentials and make sure the **Active** checkbox is checked.
+1. Click **Save changes**.
+
+## Status Page UI
+
+The Status page landing page shows you an overview of the recent incidents. Clicking on an incident will take you to the incident's detail page.
+
+![Status Page landing page](../img/status_page_incidents_v12_10.png)
+
+### Incident detail page
+
+The incident detail page shows detailed information about a particular incident. For example:
+
+- Status on the incident, including when the incident was last updated.
+- The incident title.
+- The description of the incident.
+- A chronological ordered list of updates to the incident.
+
+![Status Page detail](../img/status_page_detail_v12_10.png)
+
+## How it works
+
+### Publishing Incidents
+
+To publish an Incident, you first need to create an issue in the Project you enabled the Status Page settings in.
+
+Once this issue is created, a background worker will publish the issue onto the status page using the credentials you provided during setup.
+
+### Publishing updates
+
+To publish an update to the Incident, update the incident issue's description.
+
+### Adding comments
+
+To add comments to the Status Page Incident, create a comment on the incident issue.
+
+When you're ready to publish the comment, add a microphone [award emoji](../../../user/award_emojis.md) reaction (`:microphone` 🎤) to the comment. This marks the comment as one which should be deployed to the Status Page.
+
+CAUTION: **Caution:**
+Anyone with access to view the Issue can add an Emoji Award to a comment, so you may want to keep your Issues limited to team members only.
+
+### Changing the Incident status
+
+To change the incident status from `open` to `closed`, close the incident issue within GitLab. This will then be updated shortly on the Status page website.
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index f4afcd962af..f8ee0ca6877 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -163,8 +163,31 @@ module Gitlab
signup_enabled: alt_usage_data { Gitlab::CurrentSettings.allow_signup? },
web_ide_clientside_preview_enabled: alt_usage_data { Gitlab::CurrentSettings.web_ide_clientside_preview_enabled? },
ingress_modsecurity_enabled: Feature.enabled?(:ingress_modsecurity)
- }
+ }.merge(features_usage_data_container_expiration_policies)
+ end
+
+ # rubocop: disable CodeReuse/ActiveRecord
+ def features_usage_data_container_expiration_policies
+ results = {}
+ start = ::Project.minimum(:id)
+ finish = ::Project.maximum(:id)
+
+ results[:projects_with_expiration_policy_disabled] = distinct_count(::ContainerExpirationPolicy.where(enabled: false), :project_id, start: start, finish: finish)
+ base = ::ContainerExpirationPolicy.active
+ results[:projects_with_expiration_policy_enabled] = distinct_count(base, :project_id, start: start, finish: finish)
+
+ %i[keep_n cadence older_than].each do |option|
+ ::ContainerExpirationPolicy.public_send("#{option}_options").keys.each do |value| # rubocop: disable GitlabSecurity/PublicSend
+ results["projects_with_expiration_policy_enabled_with_#{option}_set_to_#{value}".to_sym] = distinct_count(base.where(option => value), :project_id, start: start, finish: finish)
+ end
+ end
+
+ results[:projects_with_expiration_policy_enabled_with_keep_n_unset] = distinct_count(base.where(keep_n: nil), :project_id, start: start, finish: finish)
+ results[:projects_with_expiration_policy_enabled_with_older_than_unset] = distinct_count(base.where(older_than: nil), :project_id, start: start, finish: finish)
+
+ results
end
+ # rubocop: enable CodeReuse/ActiveRecord
# @return [Hash<Symbol, Integer>]
def usage_counters
diff --git a/spec/features/projects/navbar_spec.rb b/spec/features/projects/navbar_spec.rb
index 6dbcace5401..9dfdaf54a2f 100644
--- a/spec/features/projects/navbar_spec.rb
+++ b/spec/features/projects/navbar_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
describe 'Project navbar' do
include NavbarStructureHelper
+ include WaitForRequests
include_context 'project navbar structure'
@@ -21,6 +22,22 @@ describe 'Project navbar' do
end
end
+ context 'when value stream is available' do
+ before do
+ visit project_path(project)
+ end
+
+ it 'redirects to value stream when Analytics item is clicked' do
+ page.within('.sidebar-top-level-items') do
+ find('[data-qa-selector=analytics_anchor]').click
+ end
+
+ wait_for_requests
+
+ expect(page).to have_current_path(project_cycle_analytics_path(project))
+ end
+ end
+
context 'when pages are available' do
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
diff --git a/spec/frontend/ide/services/index_spec.js b/spec/frontend/ide/services/index_spec.js
index 55f174f4663..658ad37d7f2 100644
--- a/spec/frontend/ide/services/index_spec.js
+++ b/spec/frontend/ide/services/index_spec.js
@@ -42,6 +42,87 @@ describe('IDE services', () => {
});
});
+ describe('getRawFileData', () => {
+ it("resolves with a file's content if its a tempfile and it isn't renamed", () => {
+ const file = {
+ path: 'file',
+ tempFile: true,
+ content: 'content',
+ raw: 'raw content',
+ };
+
+ return services.getRawFileData(file).then(raw => {
+ expect(raw).toBe('content');
+ });
+ });
+
+ it('resolves with file.raw if the file is renamed', () => {
+ const file = {
+ path: 'file',
+ tempFile: true,
+ content: 'content',
+ prevPath: 'old_path',
+ raw: 'raw content',
+ };
+
+ return services.getRawFileData(file).then(raw => {
+ expect(raw).toBe('raw content');
+ });
+ });
+
+ it('returns file.raw if it exists', () => {
+ const file = {
+ path: 'file',
+ content: 'content',
+ raw: 'raw content',
+ };
+
+ return services.getRawFileData(file).then(raw => {
+ expect(raw).toBe('raw content');
+ });
+ });
+
+ it("returns file.raw if file.raw is empty but file.rawPath doesn't exist", () => {
+ const file = {
+ path: 'file',
+ content: 'content',
+ raw: '',
+ };
+
+ return services.getRawFileData(file).then(raw => {
+ expect(raw).toBe('');
+ });
+ });
+
+ describe("if file.rawPath exists but file.raw doesn't exist", () => {
+ let file;
+ let mock;
+ beforeEach(() => {
+ file = {
+ path: 'file',
+ content: 'content',
+ raw: '',
+ rawPath: 'some_raw_path',
+ };
+
+ mock = new MockAdapter(axios);
+ mock.onGet(file.rawPath).reply(200, 'raw content');
+
+ jest.spyOn(axios, 'get');
+ });
+
+ afterEach(() => {
+ mock.restore();
+ });
+
+ it('sends a request to file.rawPath', () => {
+ return services.getRawFileData(file).then(raw => {
+ expect(raw).toEqual('raw content');
+ });
+ });
+ });
+ });
+
describe('getBaseRawFileData', () => {
let file;
let mock;
diff --git a/spec/frontend/ide/stores/actions/file_spec.js b/spec/frontend/ide/stores/actions/file_spec.js
index 6df963b0d55..43cb06f5d92 100644
--- a/spec/frontend/ide/stores/actions/file_spec.js
+++ b/spec/frontend/ide/stores/actions/file_spec.js
@@ -408,7 +408,7 @@ describe('IDE store file actions', () => {
beforeEach(() => {
jest.spyOn(service, 'getRawFileData');
- tmpFile = file('tmpFile');
+ tmpFile = { ...file('tmpFile'), rawPath: 'raw_path' };
store.state.entries[tmpFile.path] = tmpFile;
});
diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb
index 9457e2cd549..a46778bb6c3 100644
--- a/spec/lib/gitlab/usage_data_spec.rb
+++ b/spec/lib/gitlab/usage_data_spec.rb
@@ -144,6 +144,43 @@ describe Gitlab::UsageData, :aggregate_failures do
expect(subject[:gitlab_shared_runners_enabled]).to eq(Gitlab.config.gitlab_ci.shared_runners_enabled)
expect(subject[:web_ide_clientside_preview_enabled]).to eq(Gitlab::CurrentSettings.web_ide_clientside_preview_enabled?)
end
+
+ context 'with existing container expiration policies' do
+ let_it_be(:disabled) { create(:container_expiration_policy, enabled: false) }
+ let_it_be(:enabled) { create(:container_expiration_policy, enabled: true) }
+ %i[keep_n cadence older_than].each do |attribute|
+ ContainerExpirationPolicy.send("#{attribute}_options").keys.each do |value|
+ let_it_be("container_expiration_policy_with_#{attribute}_set_to_#{value}") { create(:container_expiration_policy, attribute => value) }
+ end
+ end
+
+ let(:inactive_policies) { ::ContainerExpirationPolicy.where(enabled: false) }
+ let(:active_policies) { ::ContainerExpirationPolicy.active }
+
+ it 'gathers usage data' do
+ expect(subject[:projects_with_expiration_policy_enabled]).to eq 16
+ expect(subject[:projects_with_expiration_policy_disabled]).to eq 1
+
+ expect(subject[:projects_with_expiration_policy_enabled_with_keep_n_unset]).to eq 10
+ expect(subject[:projects_with_expiration_policy_enabled_with_keep_n_set_to_1]).to eq 1
+ expect(subject[:projects_with_expiration_policy_enabled_with_keep_n_set_to_5]).to eq 1
+ expect(subject[:projects_with_expiration_policy_enabled_with_keep_n_set_to_10]).to eq 1
+ expect(subject[:projects_with_expiration_policy_enabled_with_keep_n_set_to_25]).to eq 1
+ expect(subject[:projects_with_expiration_policy_enabled_with_keep_n_set_to_50]).to eq 1
+
+ expect(subject[:projects_with_expiration_policy_enabled_with_older_than_unset]).to eq 12
+ expect(subject[:projects_with_expiration_policy_enabled_with_older_than_set_to_7d]).to eq 1
+ expect(subject[:projects_with_expiration_policy_enabled_with_older_than_set_to_14d]).to eq 1
+ expect(subject[:projects_with_expiration_policy_enabled_with_older_than_set_to_30d]).to eq 1
+ expect(subject[:projects_with_expiration_policy_enabled_with_older_than_set_to_90d]).to eq 1
+
+ expect(subject[:projects_with_expiration_policy_enabled_with_cadence_set_to_1d]).to eq 12
+ expect(subject[:projects_with_expiration_policy_enabled_with_cadence_set_to_7d]).to eq 1
+ expect(subject[:projects_with_expiration_policy_enabled_with_cadence_set_to_14d]).to eq 1
+ expect(subject[:projects_with_expiration_policy_enabled_with_cadence_set_to_1month]).to eq 1
+ expect(subject[:projects_with_expiration_policy_enabled_with_cadence_set_to_3month]).to eq 1
+ end
+ end
end
describe '#components_usage_data' do
diff --git a/spec/support/helpers/usage_data_helpers.rb b/spec/support/helpers/usage_data_helpers.rb
index eff252ddda0..1f1e686fb21 100644
--- a/spec/support/helpers/usage_data_helpers.rb
+++ b/spec/support/helpers/usage_data_helpers.rb
@@ -134,5 +134,24 @@ module UsageDataHelpers
prometheus_metrics_enabled
web_ide_clientside_preview_enabled
ingress_modsecurity_enabled
+ projects_with_expiration_policy_disabled
+ projects_with_expiration_policy_enabled
+ projects_with_expiration_policy_enabled_with_keep_n_unset
+ projects_with_expiration_policy_enabled_with_older_than_unset
+ projects_with_expiration_policy_enabled_with_keep_n_set_to_1
+ projects_with_expiration_policy_enabled_with_keep_n_set_to_5
+ projects_with_expiration_policy_enabled_with_keep_n_set_to_10
+ projects_with_expiration_policy_enabled_with_keep_n_set_to_25
+ projects_with_expiration_policy_enabled_with_keep_n_set_to_50
+ projects_with_expiration_policy_enabled_with_keep_n_set_to_100
+ projects_with_expiration_policy_enabled_with_cadence_set_to_1d
+ projects_with_expiration_policy_enabled_with_cadence_set_to_7d
+ projects_with_expiration_policy_enabled_with_cadence_set_to_14d
+ projects_with_expiration_policy_enabled_with_cadence_set_to_1month
+ projects_with_expiration_policy_enabled_with_cadence_set_to_3month
+ projects_with_expiration_policy_enabled_with_older_than_set_to_7d
+ projects_with_expiration_policy_enabled_with_older_than_set_to_14d
+ projects_with_expiration_policy_enabled_with_older_than_set_to_30d
+ projects_with_expiration_policy_enabled_with_older_than_set_to_90d
).freeze
end