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>2019-12-03 18:06:20 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-03 18:06:20 +0300
commit4204cf308596e0e26f578a6e2da88f49c0f4aad9 (patch)
tree644447bcb576a459e079318b06712b7c89416e2b /spec/lib/gitlab
parentcd4cb29b2c304f00d238ee72fe40c767cb3e2675 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r--spec/lib/gitlab/data_builder/pipeline_spec.rb1
-rw-r--r--spec/lib/gitlab/grafana_embed_usage_data_spec.rb70
-rw-r--r--spec/lib/gitlab/usage_data_spec.rb4
3 files changed, 75 insertions, 0 deletions
diff --git a/spec/lib/gitlab/data_builder/pipeline_spec.rb b/spec/lib/gitlab/data_builder/pipeline_spec.rb
index 931477d19c2..635bf56b72e 100644
--- a/spec/lib/gitlab/data_builder/pipeline_spec.rb
+++ b/spec/lib/gitlab/data_builder/pipeline_spec.rb
@@ -34,6 +34,7 @@ describe Gitlab::DataBuilder::Pipeline do
expect(build_data).to be_a(Hash)
expect(build_data[:id]).to eq(build.id)
expect(build_data[:status]).to eq(build.status)
+ expect(build_data[:allow_failure]).to eq(build.allow_failure)
expect(project_data).to eq(project.hook_attrs(backward: false))
expect(data[:merge_request]).to be_nil
end
diff --git a/spec/lib/gitlab/grafana_embed_usage_data_spec.rb b/spec/lib/gitlab/grafana_embed_usage_data_spec.rb
new file mode 100644
index 00000000000..162db46719b
--- /dev/null
+++ b/spec/lib/gitlab/grafana_embed_usage_data_spec.rb
@@ -0,0 +1,70 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::GrafanaEmbedUsageData do
+ describe '#issue_count' do
+ subject { described_class.issue_count }
+
+ let(:project) { create(:project) }
+ let(:description_with_embed) { "Some comment\n\nhttps://grafana.example.com/d/xvAk4q0Wk/go-processes?orgId=1&from=1573238522762&to=1573240322762&var-job=prometheus&var-interval=10m&panelId=1&fullscreen" }
+ let(:description_with_unintegrated_embed) { "Some comment\n\nhttps://grafana.exp.com/d/xvAk4q0Wk/go-processes?orgId=1&from=1573238522762&to=1573240322762&var-job=prometheus&var-interval=10m&panelId=1&fullscreen" }
+ let(:description_with_non_grafana_inline_metric) { "Some comment\n\n#{Gitlab::Routing.url_helpers.metrics_namespace_project_environment_url(*['foo', 'bar', 12])}" }
+
+ shared_examples "zero count" do
+ it "does not count the issue" do
+ expect(subject).to eq(0)
+ end
+ end
+
+ context 'with project grafana integration enabled' do
+ before do
+ create(:grafana_integration, project: project, enabled: true)
+ end
+
+ context 'with valid and invalid embeds' do
+ before do
+ # Valid
+ create(:issue, project: project, description: description_with_embed)
+ create(:issue, project: project, description: description_with_embed)
+ # In-Valid
+ create(:issue, project: project, description: description_with_unintegrated_embed)
+ create(:issue, project: project, description: description_with_non_grafana_inline_metric)
+ create(:issue, project: project, description: nil)
+ create(:issue, project: project, description: '')
+ create(:issue, project: project)
+ end
+
+ it 'counts only the issues with embeds' do
+ expect(subject).to eq(2)
+ end
+ end
+ end
+
+ context 'with project grafana integration disabled' do
+ before do
+ create(:grafana_integration, project: project, enabled: false)
+ end
+
+ context 'with one issue having a grafana link in the description and one without' do
+ before do
+ create(:issue, project: project, description: description_with_embed)
+ create(:issue, project: project)
+ end
+
+ it_behaves_like('zero count')
+ end
+ end
+
+ context 'with an un-integrated project' do
+ context 'with one issue having a grafana link in the description and one without' do
+ before do
+ create(:issue, project: project, description: description_with_embed)
+ create(:issue, project: project)
+ end
+
+ it_behaves_like('zero count')
+ end
+ end
+ end
+end
diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb
index 484684eeb65..713ddca6c2b 100644
--- a/spec/lib/gitlab/usage_data_spec.rb
+++ b/spec/lib/gitlab/usage_data_spec.rb
@@ -53,6 +53,8 @@ describe Gitlab::UsageData do
create(:grafana_integration, project: projects[1], enabled: true)
create(:grafana_integration, project: projects[2], enabled: false)
+ allow(Gitlab::GrafanaEmbedUsageData).to receive(:issue_count).and_return(2)
+
ProjectFeature.first.update_attribute('repository_access_level', 0)
end
@@ -152,6 +154,7 @@ describe Gitlab::UsageData do
issues
issues_with_associated_zoom_link
issues_using_zoom_quick_actions
+ issues_with_embedded_grafana_charts_approx
keys
label_lists
labels
@@ -211,6 +214,7 @@ describe Gitlab::UsageData do
expect(count_data[:projects_with_error_tracking_enabled]).to eq(1)
expect(count_data[:issues_with_associated_zoom_link]).to eq(2)
expect(count_data[:issues_using_zoom_quick_actions]).to eq(3)
+ expect(count_data[:issues_with_embedded_grafana_charts_approx]).to eq(2)
expect(count_data[:clusters_enabled]).to eq(4)
expect(count_data[:project_clusters_enabled]).to eq(3)