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>2021-09-20 16:18:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-09-20 16:18:24 +0300
commit0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch)
tree4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/lib/gitlab/tracking
parent744144d28e3e7fddc117924fef88de5d9674fe4c (diff)
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/lib/gitlab/tracking')
-rw-r--r--spec/lib/gitlab/tracking/snowplow_schema_validation_spec.rb33
-rw-r--r--spec/lib/gitlab/tracking/standard_context_spec.rb22
2 files changed, 53 insertions, 2 deletions
diff --git a/spec/lib/gitlab/tracking/snowplow_schema_validation_spec.rb b/spec/lib/gitlab/tracking/snowplow_schema_validation_spec.rb
new file mode 100644
index 00000000000..32c601ae47d
--- /dev/null
+++ b/spec/lib/gitlab/tracking/snowplow_schema_validation_spec.rb
@@ -0,0 +1,33 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'Snowplow Schema Validation' do
+ context 'snowplow events definition' do
+ shared_examples 'matches schema' do
+ it 'conforms schema json' do
+ paths = Dir[Rails.root.join(yaml_path)]
+
+ events = paths.each_with_object([]) do |path, metrics|
+ metrics.push(
+ YAML.safe_load(File.read(path), aliases: true)
+ )
+ end
+
+ expect(events).to all match_schema(Rails.root.join('config/events/schema.json'))
+ end
+ end
+
+ describe 'matches the schema for CE' do
+ let(:yaml_path) { 'config/events/*.yml' }
+
+ it_behaves_like 'matches schema'
+ end
+
+ describe 'matches the schema for EE' do
+ let(:yaml_path) { 'ee/config/events/*.yml' }
+
+ it_behaves_like 'matches schema'
+ end
+ end
+end
diff --git a/spec/lib/gitlab/tracking/standard_context_spec.rb b/spec/lib/gitlab/tracking/standard_context_spec.rb
index a0fb6a270a5..ca7a6b6b1c3 100644
--- a/spec/lib/gitlab/tracking/standard_context_spec.rb
+++ b/spec/lib/gitlab/tracking/standard_context_spec.rb
@@ -87,8 +87,26 @@ RSpec.describe Gitlab::Tracking::StandardContext do
end
end
- it 'does not contain any ids' do
- expect(snowplow_context.to_json[:data].keys).not_to include(:user_id, :project_id, :namespace_id)
+ it 'does not contain user id' do
+ expect(snowplow_context.to_json[:data].keys).not_to include(:user_id)
+ end
+
+ it 'contains namespace and project ids' do
+ expect(snowplow_context.to_json[:data].keys).to include(:project_id, :namespace_id)
+ end
+
+ it 'accepts just project id as integer' do
+ expect { described_class.new(project: 1).to_context }.not_to raise_error
+ end
+
+ context 'without add_namespace_and_project_to_snowplow_tracking feature' do
+ before do
+ stub_feature_flags(add_namespace_and_project_to_snowplow_tracking: false)
+ end
+
+ it 'does not contain any ids' do
+ expect(snowplow_context.to_json[:data].keys).not_to include(:user_id, :project_id, :namespace_id)
+ end
end
end
end