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>2019-12-17 15:08:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-17 15:08:11 +0300
commitbadb9c1deacbea601b02f88811b7e123589d9251 (patch)
treef4b4f85db49a8c9fc9bd6233ed9f7862c9de8ded /spec
parent5bd24a54ef4ce3a38a860eb53b66d062c2382971 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/fixtures/lib/gitlab/metrics/dashboard/schemas/panel_groups.json1
-rw-r--r--spec/frontend/lib/utils/url_utility_spec.js62
-rw-r--r--spec/lib/gitlab/database/migration_helpers_spec.rb13
-rw-r--r--spec/lib/gitlab/metrics/dashboard/service_selector_spec.rb6
-rw-r--r--spec/migrations/insert_project_hooks_plan_limits_spec.rb67
-rw-r--r--spec/services/metrics/dashboard/pod_dashboard_service_spec.rb24
-rw-r--r--spec/support/helpers/metrics_dashboard_helpers.rb4
7 files changed, 145 insertions, 32 deletions
diff --git a/spec/fixtures/lib/gitlab/metrics/dashboard/schemas/panel_groups.json b/spec/fixtures/lib/gitlab/metrics/dashboard/schemas/panel_groups.json
index d7a390adcdc..f4afb4cbffc 100644
--- a/spec/fixtures/lib/gitlab/metrics/dashboard/schemas/panel_groups.json
+++ b/spec/fixtures/lib/gitlab/metrics/dashboard/schemas/panel_groups.json
@@ -2,7 +2,6 @@
"type": "object",
"required": [
"group",
- "priority",
"panels"
],
"properties": {
diff --git a/spec/frontend/lib/utils/url_utility_spec.js b/spec/frontend/lib/utils/url_utility_spec.js
index a625c9cd274..048736d75f6 100644
--- a/spec/frontend/lib/utils/url_utility_spec.js
+++ b/spec/frontend/lib/utils/url_utility_spec.js
@@ -330,46 +330,46 @@ describe('URL utility', () => {
expect(urlUtils.escapeFileUrl('foo/bar/file.md')).toBe('foo/bar/file.md');
});
});
-});
-describe('setUrlParams', () => {
- it('adds new params as query string', () => {
- const url = 'https://gitlab.com/test';
+ describe('setUrlParams', () => {
+ it('adds new params as query string', () => {
+ const url = 'https://gitlab.com/test';
- expect(
- urlUtils.setUrlParams({ group_id: 'gitlab-org', project_id: 'my-project' }, url),
- ).toEqual('https://gitlab.com/test?group_id=gitlab-org&project_id=my-project');
- });
+ expect(
+ urlUtils.setUrlParams({ group_id: 'gitlab-org', project_id: 'my-project' }, url),
+ ).toEqual('https://gitlab.com/test?group_id=gitlab-org&project_id=my-project');
+ });
- it('updates an existing parameter', () => {
- const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project';
+ it('updates an existing parameter', () => {
+ const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project';
- expect(urlUtils.setUrlParams({ project_id: 'gitlab-test' }, url)).toEqual(
- 'https://gitlab.com/test?group_id=gitlab-org&project_id=gitlab-test',
- );
- });
+ expect(urlUtils.setUrlParams({ project_id: 'gitlab-test' }, url)).toEqual(
+ 'https://gitlab.com/test?group_id=gitlab-org&project_id=gitlab-test',
+ );
+ });
- it("removes the project_id param when it's value is null", () => {
- const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project';
+ it("removes the project_id param when it's value is null", () => {
+ const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project';
- expect(urlUtils.setUrlParams({ project_id: null }, url)).toEqual(
- 'https://gitlab.com/test?group_id=gitlab-org',
- );
- });
+ expect(urlUtils.setUrlParams({ project_id: null }, url)).toEqual(
+ 'https://gitlab.com/test?group_id=gitlab-org',
+ );
+ });
- it('handles arrays properly', () => {
- const url = 'https://gitlab.com/test';
+ it('handles arrays properly', () => {
+ const url = 'https://gitlab.com/test';
- expect(urlUtils.setUrlParams({ label_name: ['foo', 'bar'] }, url)).toEqual(
- 'https://gitlab.com/test?label_name=foo&label_name=bar',
- );
- });
+ expect(urlUtils.setUrlParams({ label_name: ['foo', 'bar'] }, url)).toEqual(
+ 'https://gitlab.com/test?label_name=foo&label_name=bar',
+ );
+ });
- it('removes all existing URL params and sets a new param when cleanParams=true', () => {
- const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project';
+ it('removes all existing URL params and sets a new param when cleanParams=true', () => {
+ const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project';
- expect(urlUtils.setUrlParams({ foo: 'bar' }, url, true)).toEqual(
- 'https://gitlab.com/test?foo=bar',
- );
+ expect(urlUtils.setUrlParams({ foo: 'bar' }, url, true)).toEqual(
+ 'https://gitlab.com/test?foo=bar',
+ );
+ });
});
});
diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb
index 2ba253f9652..cac6908f4b4 100644
--- a/spec/lib/gitlab/database/migration_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migration_helpers_spec.rb
@@ -1440,4 +1440,17 @@ describe Gitlab::Database::MigrationHelpers do
end
end
end
+
+ describe '#create_or_update_plan_limit' do
+ it 'creates or updates plan limits' do
+ expect(model).to receive(:execute).with <<~SQL
+ INSERT INTO plan_limits (plan_id, "project_hooks")
+ VALUES
+ ((SELECT id FROM plans WHERE name = 'free' LIMIT 1), '10')
+ ON CONFLICT (plan_id) DO UPDATE SET "project_hooks" = EXCLUDED."project_hooks";
+ SQL
+
+ model.create_or_update_plan_limit('project_hooks', 'free', 10)
+ end
+ end
end
diff --git a/spec/lib/gitlab/metrics/dashboard/service_selector_spec.rb b/spec/lib/gitlab/metrics/dashboard/service_selector_spec.rb
index 0d4562f78f1..e0c8133994b 100644
--- a/spec/lib/gitlab/metrics/dashboard/service_selector_spec.rb
+++ b/spec/lib/gitlab/metrics/dashboard/service_selector_spec.rb
@@ -22,6 +22,12 @@ describe Gitlab::Metrics::Dashboard::ServiceSelector do
it { is_expected.to be Metrics::Dashboard::SystemDashboardService }
end
+
+ context 'when the path is for the pod dashboard' do
+ let(:arguments) { { dashboard_path: pod_dashboard_path } }
+
+ it { is_expected.to be Metrics::Dashboard::PodDashboardService }
+ end
end
context 'when the embedded flag is provided' do
diff --git a/spec/migrations/insert_project_hooks_plan_limits_spec.rb b/spec/migrations/insert_project_hooks_plan_limits_spec.rb
new file mode 100644
index 00000000000..abc2ccd0507
--- /dev/null
+++ b/spec/migrations/insert_project_hooks_plan_limits_spec.rb
@@ -0,0 +1,67 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'migrate', '20191216183532_insert_project_hooks_plan_limits.rb')
+
+describe InsertProjectHooksPlanLimits, :migration do
+ let(:migration) { described_class.new }
+ let(:plans) { table(:plans) }
+ let(:plan_limits) { table(:plan_limits) }
+
+ before do
+ plans.create(id: 34, name: 'free')
+ plans.create(id: 2, name: 'bronze')
+ plans.create(id: 3, name: 'silver')
+ plans.create(id: 4, name: 'gold')
+ plan_limits.create(plan_id: 34, ci_active_jobs: 5)
+ end
+
+ context 'when on Gitlab.com' do
+ before do
+ expect(Gitlab).to receive(:com?).at_most(:twice).and_return(true)
+ end
+
+ describe '#up' do
+ it 'updates the project_hooks plan limits' do
+ migration.up
+
+ expect(plan_limits.pluck(:plan_id, :project_hooks, :ci_active_jobs))
+ .to match_array([[34, 10, 5], [2, 20, 0], [3, 30, 0], [4, 100, 0]])
+ end
+ end
+
+ describe '#down' do
+ it 'updates the project_hooks plan limits to 0' do
+ migration.up
+ migration.down
+
+ expect(plan_limits.pluck(:plan_id, :project_hooks, :ci_active_jobs))
+ .to match_array([[34, 0, 5], [2, 0, 0], [3, 0, 0], [4, 0, 0]])
+ end
+ end
+ end
+
+ context 'when on self-hosted' do
+ before do
+ expect(Gitlab).to receive(:com?).and_return(false)
+ end
+
+ describe '#up' do
+ it 'does not update the plan limits' do
+ migration.up
+
+ expect(plan_limits.pluck(:plan_id, :project_hooks, :ci_active_jobs))
+ .to match_array([[34, 0, 5]])
+ end
+ end
+
+ describe '#down' do
+ it 'does not update the plan limits' do
+ migration.down
+
+ expect(plan_limits.pluck(:plan_id, :project_hooks, :ci_active_jobs))
+ .to match_array([[34, 0, 5]])
+ end
+ end
+ end
+end
diff --git a/spec/services/metrics/dashboard/pod_dashboard_service_spec.rb b/spec/services/metrics/dashboard/pod_dashboard_service_spec.rb
new file mode 100644
index 00000000000..c3993bf71ea
--- /dev/null
+++ b/spec/services/metrics/dashboard/pod_dashboard_service_spec.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Metrics::Dashboard::PodDashboardService, :use_clean_rails_memory_store_caching do
+ include MetricsDashboardHelpers
+
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project) }
+ let_it_be(:environment) { create(:environment, project: project) }
+
+ before do
+ project.add_maintainer(user)
+ end
+
+ describe 'get_dashboard' do
+ let(:dashboard_path) { described_class::DASHBOARD_PATH }
+ let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] }
+ let(:service_call) { described_class.new(*service_params).get_dashboard }
+
+ it_behaves_like 'valid dashboard service response'
+ it_behaves_like 'caches the unprocessed dashboard for subsequent calls'
+ end
+end
diff --git a/spec/support/helpers/metrics_dashboard_helpers.rb b/spec/support/helpers/metrics_dashboard_helpers.rb
index 98f235bdac4..5b425d0964d 100644
--- a/spec/support/helpers/metrics_dashboard_helpers.rb
+++ b/spec/support/helpers/metrics_dashboard_helpers.rb
@@ -22,6 +22,10 @@ module MetricsDashboardHelpers
Metrics::Dashboard::SystemDashboardService::DASHBOARD_PATH
end
+ def pod_dashboard_path
+ Metrics::Dashboard::PodDashboardService::DASHBOARD_PATH
+ end
+
def business_metric_title
PrometheusMetricEnums.group_details[:business][:group_title]
end