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
path: root/spec
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 /spec
parentc52b81f45762cb7f05a950689dfc6d51b197ea73 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-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
5 files changed, 155 insertions, 1 deletions
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